To give a short introduction into the testing aspects, we collected some recommendations from our experience regarding unit tests.
Tests should:
- be stateless.
- This guarantees reliability. The test should only fail if there is a bug in the code under test, not due to side effects of other tests or the environment.
- be separated from productive code.
- We recommend a separated test-folder, containing all tests. This will help you to stay organized.
- be easy to understand, which scenario they test.
- give the test function a meaningful name.
- use only one assert per test.
- avoid branching in tests. A test should only test a single aspect.
- also check negative scenarios, in order to guarantee robustness of your code.
- be written to reproduce bugs and ensure their correction for future versions.