Columns

Test tools help you brew perfect Java code

The Java programming language is one of the hottest topics in applications development today. Java is becoming the language of choice for many new application-development projects, including mission-critical applications. Mission-critical applications require extensive testing. Bugs in mission-critical applications can cost companies millions.

TESTING,TESTING

There are several features which make testing Java programs difficult. First, since Java programs are often written to run on several different computing platforms, to thoroughly test a program you will need to test it several times, once on each platform. Second, many of these platforms are so new that no application-testing tools currently exist for them.To help companies thoroughly exercise Java programs, SunTest, a unit of Sun Microsystems Inc. based in Mountain View, Calif., has just released the SunTest Suite, a set of tools for testing Java applications. The three components of the SunTest Suite are: JavaStar, a GUI test tool; JavaSpec, an API test tool; and JavaScope a coverage analysis test tool. Testers use JavaStar to test Java applications and applets via their graphical user interfaces. Like many of today's GUI test tools, Java Star can record and replay any number of mouse movements and clicks, as well as keyboard input, and automatically generate test scripts. Testers can then edit these scripts, building complex test cases from simpler ones and adding control structures and comparison code, to thoroughly test the application. JavaStar also includes all the functionality needed to control and monitor the tests.

THE SUNTEST SUITE

What makes JavaStar different from other test tools, though, is that the test scripts it generates are all in Java. Testers do not have to learn a proprietary scripting language, and if they are already proficient in Java, they will be proficient with JavaStar almost immediately. Another difference is that JavaStar works at the Java level, not the OS level, as is the case with other test tools. For example, with other test tools, a mouse click would be recorded as an OS event, but JavaStar will report the click as a Java event.

Because JavaStar is a Java program, and the test scripts are also Java programs, the tool and the scripts will run on any platform with a Java Virtual Machine (JVM). This feature makes it much easier to test programs that will run on more than one platform as there is no need to write and maintain a test script for each platform. Running a single test script on multiple platforms also means there will be no differences in test results among the platforms.

JavaSpec is a test tool used to test Java applications, applets and libraries via their application programming interfaces (APIs). JavaSpec is the right tool for testing embedded applications that do not have a GUI.

To use JavaSpec, a tester would first determine what to test and write the Java assertions that will exercise the Java code. Next, the tester uses JavaSpec to specify the input data and expected results. Finally, JavaSpec automatically runs the test, comparing the test output to the expected output and reporting on the results. JavaScope is the test suite's coverage analyzer. It provides coverage analysis for all methods, branches, logical operations and relational operations.

To use JavaScope, all the tester needs to do is add the switch, "-cov," to the Java compile command. This switch instruments the program so that JavaScope can measure the coverage while tests run. Once the tests have been run, JavaScope provides a graphical display of the test coverage. These results allow designers to properly interpret test results from JavaStar and JavaSpec and improve the tests by developing tests to cover uncovered portions of the program.

JavaSpec is a test tool used to test Java applications, applets and libraries via their APIs.

About the Author

Dan Romanchik is an engineering manager turned writer and Web developer. His current passion is amateur radio. You can read his amateur radio blog at www.blurty.com/~kb6nu.

Featured

Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.