Replies: 2 comments
-
Are you suggesting using a Behat Cucumber fixture to drive Pest directly instead of running it through Behat? |
Beta Was this translation helpful? Give feedback.
-
Hello Mike My question was probably not correctly written. I'm just wondering which tool is best suited for this or that test. For testing a login page, I can do it with Behat (as I've tried to explain here above) or I can do it with PestPhp (which is easier to write and, above all, faster to code). With PestPhp, I can write a feature test like So my question was about sharing experience: how do you deal about the choice Behat versus Pest? (when both can do the job) I'm thinking that Behat is probably more suited for testing a suite of pages : I need to connect, then click on a given button (like |
Beta Was this translation helpful? Give feedback.
-
Good morning and, first of all, thank you for PestPHP. For me at least, PestPHP has revolutionized the way unit tests are written in PHP. Writing tests with phpunit has never been sexy to me; PestPhp has changed the game.
I've used PestPhp in three projects right now and at least two are Laravel API projects. Using
$this->get()
and$this->post()
make easy to run a given route, make a lot of assertions and check f.i. if the received JSON has the correct structure, if the requested CSV file (an API to download a CSV) is well created in thestorage
folder and so on.At work, we have a dedicated Laravel project using Behat (https://docs.behat.org/en/latest/) and the idea is, in that project, to write some scenario like:
It means, in terms of PestPhp, to make a
$this->post()
with a given user object, assert the login was successful and the redirected page contains some predefined text. Easy I think.And, wait, so for that given scenario, it will be much easier to write tests using Pest than using Behat.
And here is, finally, my question : does anyone have experience with Behat and could tell me it it's possible to do without it and rewrite everything with Pest? Is this a good approach? What do you think?
Background info: our Behat project is for testing functionalities of a VueJS SPA application that is using APIs managed by a Laravel project (and that project is also making API calls to a third project). We need to be able to tests logins, what appears on screen after having clicked on a given button, upload file and make sure the file was correctly uploaded, go to the user's profile page, make a change like selecting another preferred language, validate and check if the application's language is well adapted, and so on. Thus features tests and not unit tests.
Thanks in advance for your answers.
Beta Was this translation helpful? Give feedback.
All reactions