Java Test-Driven Development Unit Testing
Learning objective: By the end of this lesson, you’ll be able to explain why highest significance is attached to unit testing level as opposed to all other levels.
The role of a Java developer
As Java developers, our direct involvement in all activities of testing is highest in the unit testing level. We will be responsible for preparing test cases, executing them, fixing the defects and providing the test summary. This direct invovement keeps reducing as the testing levels progress. This is the testing level where we can create the most impact. Effective unit testing contributes to the broader success of projects by fostering reliability and scalability in the codebase. It transforms Java developers from mere coders into skilled engineers who can deliver robust, high-quality software solutions.
Cost of a defect
The cost of a defect refers to the total effort, time, and resources required to identify, fix, and retest a software defect. As a defect progresses undetected through the various testing levels, the cost of resolving it increases significantly. This is because the complexity, impact, and scope of change needed to correct the defect become more extensive over time. If a defect lands in the production environment, then the cost of that defect includes loss of reputation and trust too.
Defects, in any large software development project, are inevitable. However, the sooner we find and fix it, the lesser the overall cost of a defect. Since unit testing is the first level of testing, defects identified and fixed here have the lowest cost.