8.3. Extreme Testing Applied
In this section we create a small Java application and employ JUnit, a Java-based open-source unit testing suite, to illustrate the concepts of Extreme Testing. The example itself is trivial; however, the concepts apply to most any programming situation.
Our example is a commandline application that simply determines whether an input value is a prime number. For brevity, the source code, check4Prime.java, and its test harness, check4PrimeTest.java, are listed in Appendix A. In this section we provide snippets from the application to illustrate the main points.
The specification of this program is as follows:
Develop a commandline application that accepts any positive integer, n, where 0 ≦ n ≦ 1,000, and determine whether it is a prime number. If n is a prime number, then the application should return a message stating it is a prime number. If n is not a prime number, then the application should return a message stating it is not a prime number. If n is not a valid input, then the application should display a help message.
Following the XP methodology and the principles listed in Chapter 5, we begin the application by designing unit tests. With this application, we can identify two discrete tasks: validating inputs and determining prime numbers. We could use black-box and white-box testing approaches, boundary-value analysis, and the decision-coverage criterion, respectively. However, the XT practice mandates a hands-off black-box approach to eliminate ...
Get The Art of Software Testing, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.