Unit testing in the Micronaut framework
In the object-oriented paradigm, an object can assume multiple behaviors. These behaviors are defined by their methods. Effective unit testing probes a single behavior of an object at a time. This doesn't translate to testing a method as a method can change its behavior by taking different execution paths (if the method has forked control flow). Therefore, essentially, a unit test will probe one execution path of a method at a time. Iteratively, we can add more unit tests to probe other execution paths in the same or other methods. This bottom-up approach relies on verifying behaviors at smaller, isolated levels so the application as a whole will work as expected.
To perform a unit test, isolation is required. Essentially, we need to isolate the object's behavior (that we want to test) while ignoring the object's interaction with other objects/components within the system. To achieve this isolation, we have various mechanisms...