You wanna be a good Symfony developer, so give the time to master the following three testing in Symfony application.
Type | TestCase (common used) | description |
---|---|---|
Unit | TestCase |
It ensures that individual units of source code (e.g. a single class or some specific method in some class) meet their design and behave as intended |
Functional | WebTestCase |
It checks the integration of the different layers of an application (from the routing to the views). |
Integration | KernelTestCase |
It tests a larger part of source code as integrated components. It uses generally the Symfony Kernel to fetch a service from the dependency injection container. |
The simplest way to start any type of tests, is to use maker bundle
:
# install the maker bundle
❯ symfony composer req --dev orm maker
# install the test bundle
❯ symfony composer req --dev symfony/test-pack
❯ symfony console make:test
# Which test type would you like?:
# [TestCase ] basic PHPUnit tests
# [KernelTestCase ] basic tests that have access to Symfony services
# [WebTestCase ] to run browser-like scenarios, but that don't execute JavaScript code
# >
Top comments (0)