Search code examples
phpsymfonyphpunitsymfony-2.3symfony-3.2

Is there a way to test Symfony application other than PHPUnit?


During an interview, project manager asked me the following question:

I see in your resume that you are using PHPUnit 4 for tests? Why don't you use the built-in testing of Symfony?

I answered:

What I know is that Symfony app testing is done via PHPUnit, which is recommended from the docs of 2.3 and 2.7. I don't know if Symfony3 comes with a testing component!

Was my answer correct? Thanks for the explanations.


Solution

  • Yes, you are correct. Symfony has a WebTestCase (extending the KernelTestCase where you can find that it extends PhpUnit) for functional testing. Additionally Symfony provides a PhpUnitBridge that provides helpful stuff for writing PHPUnit-Tests for a Symfony app, e.g. to make tests fail that use deprecated components. Both rely on PHPUnit and provide additional capabalities on top of "vanilla" phpunit.

    There are alternative testing tools, such as phpspec for writing unit tests and Behat for higher level tests (functional and acceptance testing), but both are not used inside Symfony and therefore don't really seem to be what was being asked about.