Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

"Runnability" testing of Java programs

A unique aspect of Java technology is that programs can run anywhere without recompilation. Here's how to test your programs so that you can find any runnability problems before your customers do

  • Print
  • Feedback

Page 2 of 7

It is also possible to use the Java programming language to write a program that is intentionally tied to a specific platform. If the nonportability of a program is intentional, there is little need to discover it by testing. Such programs fall outside the scope of this article.

In this article we discuss aspects of Java programs that need to be carefully examined and tested to identify where runnability problems may occur, and how to test for runnability. We'll also discuss how to measure the runnability of a Java program, keeping in mind the question: How well does the program deliver on the WORA promise? First, we'll examine some of the details of runnability, then we'll discuss how runnability testing can be incorporated into the software quality assurance process.

Differences in Java environments

In one vision of a perfect world, no testing would be necessary, and there would be no decision to make about the target environments for a program. All computer platforms' Java Runtime Environments (JREs) would be exactly the same, and a program that worked on one computer would work identically on all other computers. But that vision isn't the one promised by Java technology; it is, in fact, counter to the premise on which Java technology is based.

That premise is that the Java Runtime Environment represents the behavior of all computers with a common abstracted interface. However, the details of the actual computer must still show through the interface in some places -- so Java technology doesn't pretend to offer exactly the same behavior on all computers. Different computing platforms have different behavior, and Java technology makes it possible for Java programs to adjust to these differences.

We'll discuss how these differences may occur, what effect they may have on the behavior of a Java program, and how to ensure that the program fulfills its intended functionality on various platforms. The measurements we suggest will also help to delimit and control any expected differences in behavior.

Platform differences

The specification of the Java Runtime Environment (JRE) -- that which a program may depend on -- is quite complete, but it is not hermetically sealed. Platform differences visible from within Java programs include the size and appearance of GUI elements (as abstracted by the Abstract Windowing Toolkit (AWT)), the syntax of file names, and the details of thread-scheduling behavior. For example, a program that looks great on a 1024x800 24-bit display may not be usable on a 640x480 8-bit display. A program that looks great at one window size may, if certain crucial buttons aren't displayed, be unusable at another. A program that depends on a specific font may not work at all on a machine that doesn't have that font installed. Similarly, the syntax of a file name varies widely among the various Java platforms. The java.io.File class provides a useful level of abstraction that, if used correctly, can insulate your program from these platform specifics. However, if you write

  • Print
  • Feedback

Resources
  • Java Testing Tools from Sun include JavaStar GUI capture-replay, with the ability to write predicates that use the real Java objects; JavaScope, coverage measurement for Java programs; JavaSpec, a tool for creating method-level test programs; JavaLoad, stress testing for Java programs; JavaLoom, a static analyzer for thread behavior; and JavaPureCheck, a checker for portability of Java programs http://www.sun.com/suntest
  • James Gosling, Bill Joy, and Guy Steele, The Java Language Specification, Addison-Wesley 1996 http://java.sun.com/docs/books/jls/
  • Tim Lindholm and Frank Yellin, The Java Virtual Machine Specification, Addison-Wesley, 1996 http://java.sun.com/docs/books/vmspec/
  • Boris Beizer, Software Testing Techniques, 2nd Edition, Van Nostrand Reinhold, 1990 http://www.faqs.org/faqs/software-eng/part3/section-13.html
  • G. Rothermel and M. J. Harrold, "Selecting Regressions Tests for Object-oriented Software," Proceedings of the Conference on Software Maintenance, IEEE Computer Society Press, 1994, pp. 14-25 http://www.computer.org/
  • R. M. Poston, "Automated Testing from Object Models," Communications of the ACM, 1994, 37 (9), pp. 48-58 http://www.acm.org/pubs/
  • D.E. Perry and G.E. Kaiser, "Adequate Testing and Object-oriented Programming," Journal of Object-oriented Programming, 1990, 2 (5), pp. 13-19 http://www.sigs.com/publications/joop/
  • Roger Hayes, 100% Pure Java Cookbook, Sun Microsystems Inc. 1998 http://java.sun.com/100percent/cookbook.html