If you are not writing tests yet, you should start. Tests will improve the quality of your code, reduce bugs and probably force you to think more about design and quality. Actually, the hardest thing is to start and figure out which type of tests to write.
So you start researching and you find a lot of different materials and get even more confused.Even when you decide what type of tests to use, it can be hard to decide how to test some specific logic in your app.
Don’t give up! We have some tips we learned along the way that will hopefully make your life easier. In this talk you will hear about different test types and when to use them. We’ll also show some tools for checking quality of your test.
10. Unit tests
Unit testing is a level of testing where individual
units/components are tested. The purpose is to
validate that each separate unit performs as expected.
A unit is the smallest testable part of any software.
11.
12. It’s not unit tests, it’s you!
Refactor your code using SOLID principles.
16. When to use integration tests
Validation
3rd party integration
Database queries
Verifying two or more modules which have unit tests work as expected
together
18. Functional tests
In each functional tests check:
Response code
Response header
Response content: contains expected fields in expected
format
19. Functional tests
Test that each endpoint behaves as expected for:
OK request and response
Bad request and Validation response
Forbidden access response
38. The test Http Client in API Platform
Created for PHPUnit
Manipulates the Symfony HttpKernel directly to simulate HTTP requests
and responses
Huge performance boost compared to triggering real network requests
44. Postman tests + Newman
Run and test a Postman Collection directly from the command line
45. Conclusion
• You should write tests!
• It’s important to write Unit, Integration and Functional tests
• If something is hard to test - refactor it
• Check out the tools we mentioned