For framework developers, writing unit tests is a must. These tests will help developers
to verify if their changes in the code base break anything. Without unit tests, it would
be so scary to make code changes. For API/service developers, it is encouraged to write
unit tests to facilitate CI/CD devops flow.
There are two type of test cases and they serve different purposes and will be triggered
at different step of life cycle. In this section, we are focus on unit tests. There is
another article that discusses integration tests.
Unit tests will be executed every time the code is changed and they may be executed many
times a day. They need to run as fast as possible so that developers will enjoy running
them. They need to cover the majority of branches in the code but without
dependencies to external systems.
The unit tests sit in /src/test folder as default and they have class names like Test and
method names prefix with test, to indicate that they are test cases.
The majority of our unit tests were written in Junit 4.12 and we are in a transition to Junit
5 now. To use Junit5, you need to put the dependency into the parent pom.