These are chat archives for Behat/Behat

22nd
Nov 2017
Abdul Wahhab Qureshi
@forceedge01
Nov 22 2017 10:21
Behat usually sits outside of your production code. You can mock the server response i.e host hack your machine to and return a result, or using DI program to inject a mock API object when running your tests. Since behat and the code setup are separate processes it will be hard to do just with one setup. Here is an idea, not sure how your application is structured but if you you integrate this extension https://github.com/ciaranmcnulty/behat-localwebserverextension, this will fire off a local web server before running the tests, before it does that if you can programatically swap the API class for a mock, that should in theory do your job. And if you manage to do all this, It would be awesome if you could share that knowledge. :) :)
Rafaella Olandim
@rafasellas_twitter
Nov 22 2017 12:45
Hello!
Please, use the default page object in Behat, do you have suggestions or positive or negative experiences?
Admiral Husker
@admiral_husker_twitter
Nov 22 2017 16:14
@bitwombat @forceedge01 thanks you both for answering. I went with your solution @forceedge01 but i don't like the fact that the database state could be different from what it is when the user is actually using the app. I mean, if the controller action does more than just creating a request my scenario will miss that. That's acceptable though for the small piece of software i try to test so thanks again :)
Abdul Wahhab Qureshi
@forceedge01
Nov 22 2017 17:33
@admiral_husker_twitter From my experience to isolate your testing scenarios properly and to speed up testing it is important to create all preconditions programmatically where you can. Your controller could create the data by submitting a request, but that is a test on its own. If you are to couple the fact that your request is created by the web UI interaction then that means if you have an issue with creating your request, then all scenarios will fail due to the fact that they are coupled which is incorrect. What I would want a test to do is to point me towards where the problem is with concise information, if 5 of my scenarios are failing because of one interaction not working properly i.e creating the request, then i cannot quantify how big the problem is, or most probably wrongly quantify it. So to isolate the concerns, one scenario should test creation of the request. Once you've validated that bit, you don't want to re-test that bit, so create it programmatically as a precondition. I hope this makes sense :) Glad to help.
@rafasellas_twitter not sure what you mean
Rafaella Olandim
@rafasellas_twitter
Nov 22 2017 18:48
Hello!
Please, have you used the page object in Behat, do you have suggestions or positive or negative experiences?
Tiko Lakin
@tikolakin
Nov 22 2017 21:50
@here is there anyone using behat 3 with nvim?