Applying a Java Unit Testing Framework
Applying a Java Unit Testing Framework
By: Java News Desk
Oct. 5, 2006 11:30 AM
For Best Results
If your code is difficult to test, this presents an opportunity to improve your design.
If you improve your design so that it is easier to test, a better design will usually result.
Run all tests as often as possible, ideally every time you change your code. All unit tests should run at 100 percent pass rates. Frequent testing will give you confidence that your changes didn't break anything and has the additional benefit of lowering your overall stress level.
The output from these tools is the beginning of increased visibility into the development process, providing metrics that measure improved quality practices.
Automation/repeatability – Level 3
Automated unit testing lets you run tests repeatedly (regression testing), and collect tests into suites as you develop your code, promoting the evolution of your design. The key to attaining this step is that your team must have successfully implemented the first two levels.
Measurement – Level 4
To introduce new development practices, metrics must be used to identify where resource should best be deployed. For example, with unit testing, pass rate is a key measurement. Is it enough that all 5,000 unit tests have passed? If 100 percent of those tests pass, this may be a sufficient level of quality. However, if the 5,000 unit tests only cover 20 percent of the code base, the code quality level is less certain.
Only by measuring and combining results, can organizations obtain a clear picture of unit testing coverage, and ultimately code quality.
Analytics – Level 5
Trend Analysis – Level 6
If an organization is combining data from different sources, analyzing trends, and then using the results to adjust and streamline unit testing, they are to be congratulated. At this stage, they have optimized the efficiency and quality of projects and deployed applications, with a resulting decrease in customer complaints.
Java testing frameworks such as JUnit, however, work at the individual developer level and provide metrics in snapshot format. JUnit does not consolidate data from each individual client copy; or show who is responsible for untested code across an entire code set.
What is needed is a tool that not only consolidates code coverage information from all developers, but also tracks metrics over time. For example, a measured activity of code coverage may show that 70 percent of the code base is covered by unit tests. At first glance, this may seem like a good figure; but if last week's figure was 80 percent or the code base has halved in size from the previous week, how does this figure compare? These measurements must be taken in context, by individuals and by the entire team.
Refining the quality process is an ongoing task, especially with external factors enforcing the change process (such as Sarbanes-Oxley.). However, if an organization is at this point in the process, these changes will be easier to implement, with less financial impact, because a unit testing framework is already in place for all developers, allowing organizations to take positive action.
Enerjy CQ2 provides a turnkey solution including: Discovery, Recommendation, Installation, Implementation and Training.
Who Is Enerjy Software?
Development managers can now optimize the performance of their development team, thus minimizing time wasted on avoidable rework, on tracking down bugs, and in lengthy or ineffective code reviews.
Enerjy Software is a division of Teamstudio, Inc. With headquarters in Beverly, Massachusetts, Teamstudio also has offices in the UK, France, and Japan. To learn more about software integrity solutions designed to improve application quality and enhance developer productivity, please visit Enerjy's Web site at: www.enerjy.com.
Reader Feedback: Page 1 of 1