Member-only story

Symfony’s Panther: Unleash the Tests Beast

End-to-end tests are going savagely easy

Alexandre Daubois
5 min readDec 7, 2021
Panther logo from Github

Testing an application isn’t the easiest thing on earth, it is not the quickest thing either and it may not be the most exciting part of an application development. But that’s just a necessary thing. You can’t take the risk of making your application crash and loose users — and maybe money at the same time. You got to be relaxed when pushing new code edits to your production. Tests exist for this reason and check the non-regression of your application. If your tests pass (and you wrote good tests, which is another whole and huge topic), you’ll be way more confident about sending new features and bugfix to your production without the fear of breaking everything.

We can roughly find three main types of tests when creating application:

1. Unit tests, which consists in testing little snippets of codes, like functions or maybe classes. It doesn’t involve anything more than the executed code and you mock external dependencies like the database by creating fake datasets (in the test code for example) just for those tests. They are really fast to execute ;

2. Functional tests, which test in general a feature in its globality, without having to worry on how things are done internally. A common use case of functional tests is API testing: you check that by calling a specific API URL with specific arguments, you’ll have a determined response from it. They have generally external dependencies with a database running. That’s why they can be sometimes a bit slow to execute, and most of the time way slower than unit tests ;

3. End-to-end tests, which are the most complete but also the most complex ones to write and maintain. They consist of testing your application in a real web browser. Which is amazing, but also long to set up and keep relevant. Giving your testing real pages with HTML, CSS and Javascript with an automated web browser, and that you’ll probably mock a really few services used by your application, they are generally slower and heavier to execute than functional tests.

It is alway a matter of compromises: do you prefer to write tests super quickly but that only assure some code parts are fully working, or long and heavy tests that check a whole workflow and…

--

--

Alexandre Daubois
Alexandre Daubois

Written by Alexandre Daubois

Lead Developer at Wanadev // Open-source contributor

No responses yet

Write a response