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.
Dont 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. Well also show some tools for checking quality of your test.
7. Functional tests
In each functional tests check:
Response code
Response header
Response content: contains expected fields in expected
format
8. Functional tests
Test that each endpoint behaves as expected for:
OK request and response
Bad request and Validation response
Forbidden access response
11. Open API
Allows you to specify:
Available endpoints and operations
Input and output parameters for each operation
Authentication methods
Contact information, license, terms of use and other information.
An API description format for REST APIs
31. 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.
45. When to use integration tests
Validation
3rd party integration
Database queries
Verifying two or more modules which have unit tests work as
expected together
47. Event Time Category Gender Distance Disqualified Race Category
1 NULL a1 male long FALSE Individual/Team
1 2:00:00 a2 male long TRUE Individual/Team
1 2:00:00 a4 male long FALSE Him & Her
1 2:01:00 a1 male long FALSE Individual/Team
1 2:05:00 a2 female long FALSE Individual/Team
1 2:10:00 a1 male long FALSE Individual/Team
1 2:10:00 a2 female long FALSE Individual/Team
1 2:40:00 a3 male medium FALSE Individual/Team
1 3:10:00 a2 female long FALSE Individual/Team
2 2:15:00 a2 female long FALSE Individual/Team
48. Event Time Category Gender Distance Disqualified Race Category
1 NULL a1 male long FALSE Individual/Team
1 2:00:00 a2 male long TRUE Individual/Team
1 2:00:00 a4 male long FALSE Him & Her
1 2:01:00 a1 male long FALSE Individual/Team
1 2:05:00 a2 female long FALSE Individual/Team
1 2:10:00 a1 male long FALSE Individual/Team
1 2:10:00 a2 female long FALSE Individual/Team
1 2:40:00 a3 male medium FALSE Individual/Team
1 3:10:00 a2 female long FALSE Individual/Team
2 2:15:00 a2 female long FALSE Individual/Team
49. Event Time Category Gender Distance Disqualified Race Category
1 NULL a1 male long FALSE Individual/Team
1 2:00:00 a2 male long TRUE Individual/Team
1 2:00:00 a4 male long FALSE Him & Her
1 2:01:00 a1 male long FALSE Individual/Team
1 2:05:00 a2 female long FALSE Individual/Team
1 2:10:00 a1 male long FALSE Individual/Team
1 2:10:00 a2 female long FALSE Individual/Team
1 2:40:00 a3 male medium FALSE Individual/Team
1 3:10:00 a2 female long FALSE Individual/Team
2 2:15:00 a2 female long FALSE Individual/Team
50. Event Time Category Gender Distance Disqualified Race Category
1 NULL a1 male long FALSE Individual/Team
1 2:00:00 a2 male long TRUE Individual/Team
1 2:00:00 a4 male long FALSE Him & Her
1 2:01:00 a1 male long FALSE Individual/Team
1 2:05:00 a2 female long FALSE Individual/Team
1 2:10:00 a1 male long FALSE Individual/Team
1 2:10:00 a2 female long FALSE Individual/Team
1 2:40:00 a3 male medium FALSE Individual/Team
1 3:10:00 a2 female long FALSE Individual/Team
2 2:15:00 a2 female long FALSE Individual/Team
51. Event Time Category Gender Distance Disqualified Race Category
1 NULL a1 male long FALSE Individual/Team
1 2:00:00 a2 male long TRUE Individual/Team
1 2:00:00 a4 male long FALSE Him & Her
1 2:01:00 a1 male long FALSE Individual/Team
1 2:05:00 a2 female long FALSE Individual/Team
1 2:10:00 a1 male long FALSE Individual/Team
1 2:10:00 a2 female long FALSE Individual/Team
1 2:40:00 a3 male medium FALSE Individual/Team
1 3:10:00 a2 female long FALSE Individual/Team
2 2:15:00 a2 female long FALSE Individual/Team
52. Event Time Category Gender Distance Disqualified Race Category
1 NULL a1 male long FALSE Individual/Team
1 2:00:00 a2 male long TRUE Individual/Team
1 2:00:00 a4 male long FALSE Him & Her
1 2:01:00 a1 male long FALSE Individual/Team
1 2:05:00 a2 female long FALSE Individual/Team
1 2:10:00 a1 male long FALSE Individual/Team
1 2:10:00 a2 female long FALSE Individual/Team
1 2:40:00 a3 male medium FALSE Individual/Team
1 3:10:00 a2 female long FALSE Individual/Team
2 2:15:00 a2 female long FALSE Individual/Team
53. Event Time Category Gender Distance Disqualified Race Category
1 NULL a1 male long FALSE Individual/Team
1 2:00:00 a2 male long TRUE Individual/Team
1 2:00:00 a4 male long FALSE Him & Her
1 2:01:00 a1 male long FALSE Individual/Team
1 2:05:00 a2 female long FALSE Individual/Team
1 2:10:00 a1 male long FALSE Individual/Team
1 2:10:00 a2 female long FALSE Individual/Team
1 2:40:00 a3 male medium FALSE Individual/Team
1 3:10:00 a2 female long FALSE Individual/Team
2 2:15:00 a2 female long FALSE Individual/Team
66. Do I need to write tests first?
Its just one of the approaches
67. Do I need to have 100% coverage?
100% coverage doesnt guarantee your code is
fully tested and working
68. What about legacy code?
1. Start replicating bugs with tests before fixing them
2. Test at least most important and critical parts
69. How do I test some specific code?
Check out the tests of the libraries and framework you
are using
70. How do I know if the tests I wrote are good
enough?
Ask yourself:
Am I sure the code I tested works as it should?
71. Conclusion
You should write tests!
Its important to write Unit, Integration and Functional tests
If something is hard to test - refactor it
Check out the tools we mentioned