Unit testing overview
Unit testing is a strategy for testing discrete units of source code. From a programmer's perspective, a unit is the smallest testable part of an application. A unit of source code is usually defined as a public method that is callable within the application and has a specific purpose. Unit testing of the DAO layer will ensure that each public method has at least one appropriate test case. In practice, we will need many more test cases than just a single one for each public method. For example, every DAO find(ID)
method requires at least two test cases: one with an outcome returning a valid found object and one with an outcome that does not find a valid object. As a result, for every line of code written, developers often need several lines of test code.
Unit testing is an art form that takes time to master. Our goal is to establish a set of tests that cover as many scenarios as possible. This is inherently opposite to what we are trying to achieve as developers, where...