Technical Mid Level

How do you test a Symfony application? Explain your approach to unit tests, functional tests, and when you use the WebTestCase.

Quick Tip

Show the layers: "I unit test services with mocked repositories. Functional tests with WebTestCase cover the full request cycle — routing, security, persistence. I use SQLite for speed in CI and run a MySQL suite before deploy."

What good answers include

Unit tests: test services and entities in isolation with PHPUnit, mock dependencies. Functional tests with WebTestCase: boot the kernel, create a client, make HTTP requests, and assert on responses — tests the full stack including routing, security, and database. Use KernelTestCase when you need the container but not HTTP. Strong candidates discuss: test databases (SQLite for speed or matching production DB for accuracy), fixtures, transaction rollback between tests, and the balance between fast unit tests and confidence-building functional tests.

What interviewers are looking for

Tests professional development practices. Candidates who only write unit tests miss integration bugs. Those who only write functional tests have slow suites. Look for a balanced approach with clear reasoning about what each layer covers.

← All Symfony questions