1

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.

Adib Aroui
  • 4,981
  • 5
  • 42
  • 94
  • 7
    Sounds like the PM doesn't really know what they'r'e talking about. Which generally comes as part of the job in my experience. Symfony does have some bits and pieces you can build on top of e.g. WebTestCase for integration / functional testing, but it's still used via PHPUnit iirc. – Jonnix Apr 26 '17 at 12:08
  • @JonStirling, Thanks for the explanation – Adib Aroui Jul 29 '19 at 17:01

2 Answers2

3

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.

dbrumann
  • 16,803
  • 2
  • 42
  • 58
0

Additional information to your answer: In my experience, WebTestCase also bootstrap kernel as static method in all test. Due to that, is not so good to Unit testing by that tool, as this test should be fast. They design this with functional testing controllers and actions but to not need start HTTP server.

Then for:

  • unit testing, build-in in is not good option
  • functional testing, it was original intention, but i think, Behat is better solution
  • system testing - not so good.

Summary, that is why i don't use this tool.

timiTao
  • 1,417
  • 3
  • 20
  • 34