samedi 3 novembre 2018

Does it make sense to mock things when using Selenium?

I've done a bit of digging around and I was unable to find any solution that allows you to do the following;

  1. Mock some services in your PHP app
  2. Boot up a selenium instance
  3. Instruct it to make a request to your PHP app (/w mocked services)

Obviously this doesn't work because whichever testing framework you're using to mock services runs it's own PHP process, and a separate one is started once Selenium makes an HTTP request, and each process has it's own container instance.

Is the reason I haven't found anything that is able to do this simply that you shouldn't ever want to do this? I can imagine that with proper separation of things this functionality would never be needed, as UI/javascript behaviour should really be decoupled from server side business logic.

I figured that a valid use case would be the following;

You need to have some data stored in the session, e.g. recently viewed products for an ecommerce app, but you don't want to instruct selenium to actually view a bunch of products first since this is already covered in a different test, and the assertions that you want to make rely on javascript being executed.

Aucun commentaire:

Enregistrer un commentaire