Open pdoreau opened 8 years ago
What does prevent you from using a simple functional test?
Execution time. I'm using functional, more precisely API tests (see previous assert). It works, but execution time is slow, much slower than fine granularity tests. Consequently, feedback about test results (for now about 250 API tests) is slow and slow down the developement process...more and more Thanks to this bundle, I replaced some API test by faster tests which don't require booting the kernel, loading all the bundles, handling HTTP requests.... I'm looking for a way to do the same for entities validation.
With simple functional test i referred to your
much slower than a unit test or simple functional test
Our Form Tests looks like this. We boot the kernel just once and only test the form itself, not the MVC layer.
Ok that's fine to test your FormType (simalar to http://symfony.com/doc/current/cookbook/form/unit_testing.html). But it doesn't test that your entities has the right validation metadata on properties (example @Assert\NotBlank).
Yes, it looks similar to the Form Unit Testing, but its an integration test. The Symfony\Component\Form\Test\TypeTestCase
just uses a minimal setup.
The Symfony\Bundle\FrameworkBundle\Test\KernelTestCase
will boot the complete kernel (as id would be done by a functional test). Therefore it will also test the constraints on your entities.
Hello. Imagine a lot of form validation constraints, applied with annotations on entities. To test them, functional web test cases (REST API), with assertions such as :
$this->assertEquals('My error message...', $data['errors']['children']['myProperty']['errors'][0]);
It works, but it takes too much time, much slower than a unit test or simple functional test (example Repository test). Is there a way to test that in a faster and more isolated way using NoFrameworkBundle ? Thanks