HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

2031 S. Myrtle Ave.
Monrovia, CA 91016
888 305-0041

Test Environment:
Toshiba Satellite Pro 4600, 866
MHz Intel Pentium III processor,
20GB disk, 256MB RAM,
Windows 2000 w/Service Pack 2

Platforms: Windows NT/2000/98/ME, Linux, Solaris
Pricing: $3,495/developer

New-car buyers often fear that they're getting a "Friday afternoon" vehicle - a car built by the last shift at the end of a tough week. Manufacturers have spent an untold number of man-years trying to prevent such defects.

As developers you face the same problem: no matter how carefully you work, you'll inevitably make mistakes. The quality assurance department within your organization should be able to catch your mistakes before they make it into production, but they're the last line of defense. Ideally, you'll want to test your code before it makes its way over to the QA department. The sooner you find the problem, the easier it is to fix.

A number of products can help you test your code - but many of these solutions require you to write complicated test routines and scripts. These scripts often get out of sync with the code as project deadlines grow short. ParaSoft offers a fresh alternative with their Jtest 4.0 product.

Jtest Particulars
Jtest, itself a Java application, provides three different types of testing for your Java code:

  • Static testing
  • White-box testing
  • Black-box testing

    The simplest of these is static testing. Jtest compares your Java source code against a set of predefined coding rules, checking source code against a variety of rules from over 20 different categories. As a programmer I generally dislike this type of automated source-code checking because it rarely takes into account my personal coding style. However, static testing is an invaluable resource for project managers as it helps ensure that coding styles are consistent across developers and programs. It's much easier to support and maintain code that's been built in a consistent fashion across modules. In this era of "guerilla" software development, such consistency checking is doubly important. Jtest allows you to edit the static testing rules, making the entire process much more palatable. Figure 1 shows the Jtest rules list in the overlay window.

    You can pick and choose from the list of prebuilt rules, and you can use the RuleWizard to add customized rules. The complete set is then stored as a file that can be shared among developers. Thus the project manager can configure a single set of rules that can be applied across an entire team of developers. I was able to use Jtest on some sample Java code (as shown in Figure 1) and it quickly pointed out some of the most common mistakes. (Jtest can't access JAR-based code, for example, and you have to provide Java source files for static analysis.)

    Figure 1
    Figure  1:

    The second layer of testing offered by Jtest, white-box testing, checks to ensure that a class is structurally sound. (It doesn't attempt to verify that a class behaves according to specification.) With Jtest you may need to create some "test classes" to thoroughly exercise certain types of code (such as EJBs, RMI, and application server integration).

    Black-box testing checks that a class behaves according to specification (test cases the user generates). It checks that the class produces the correct output (outcomes) for a given input (or set of inputs). Jtest can derive inputs from your code by using Design by Contract (DbC) instrumentation, and you can also create explicit test classes that Jtest will use to exercise your code. (Jtest's static tests can help you to verify that the DbC assertions are contained within your Java code.)

    ParaSoft provides extensive documentation on its Web site, including tutorials, FAQs, and user manuals. I was relatively impressed with the amount of information available there for developers, and I encourage you to take a look. When the time comes to run a trial of the software, you can download it from the site, though you'll need to request a license key for Jtest. The key is machine-specific, that is, you can't use the software on multiple machines without requesting multiple license keys.

    I was able to get the software installed quickly and easily. Jtest uses a Java-based user interface, and it's relatively speedy. The UI maps errors and deficiencies back to your Java source code, but it doesn't automatically coordinate the outline controls in the display windows. (You can select an error condition in the results display and Jtest will open up the appropriate detailed results window, but it's up to you to click through the detailed results window to get to the specific line items.) Jtest automatically handles regression testing, so I was able to make iterative changes to my code and fix errors as I went along.

    JDJ Product Snapshot

  • Target audience: Java project managers, Q/A team, Java programmers
  • Level: Entry level to advanced
  • Pros: Comprehensive testing, multiplatform support, reasonably priced
  • Cons: No automated GUI testing, limited integration with popular Java IDEs

    Jtest 4.0 offers a nice platform for building consistent, well-tested Java applications. The integration of static, white-box, and black-box testing makes Jtest an interesting product, but to harness the complete power of Jtest you'll need to invest in the Design by Contract programming methodology.

    Author Bio
    Jim Milbery is an independent software consultant based in Easton, Pennsylvania. [email protected]

    All Rights Reserved
    Copyright ©  2004 SYS-CON Media, Inc.
      E-mail: [email protected]

    Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.