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

Tools of the trade, Part 2

Jtest statically and dynamically analyzes your Java code

  • Print
  • Feedback

Page 2 of 7

I explore Jtest 4.5h in this article. After introducing you to that version's user interfaces (UIs), I show, via several code examples, how to use Jtest to perform static and dynamic analysis tests. I also show you how to customize Jtest. Once you complete this article, I invite you to obtain a copy of Jtest and explore that tool's extensive documentation, which includes a tutorial.

Note
Jtest is part Java and part non-Java, and supports a variety of platforms. After installing the evaluation copy, you must obtain a license from Parasoft to try Jtest for a limited time period. Follow Parasoft's instructions to install the license.


Explore Jtest's Class and Project Testing UIs

Jtest lets you test individual classes or a set of classes that constitutes a project (such as an application or an applet). For individual class testing, Jtest presents a Class Testing UI. For class-set testing, Jtest presents a Project Testing UI. The Class Testing UI is Jtest's default testing UI.

Note
Jtest also lets you test individual JSP pages via the Class Testing UI and a set of JSP pages via the Project Testing UI. Because JSP (JavaServer Pages) is part of Java 2 Platform, Enterprise Edition (J2EE), and because Java 101 is Java 2 Platform, Standard Edition (J2SE)-specific, I do not discuss Jtest's JSP-testing support in this article.


Use the Class Testing UI to test individual classes. This UI also lets you study the results of a class tested as part of a project test, and consists of a menu bar, a toolbar, a Class Name panel, a Test Progress panel, an Errors Found panel, and a status bar:

  • Menu bar: At the top of the Class Testing UI is a menu bar with File, Test, View, Preferences, Tools, Window, and Help menus. File menu items control basic test functionality; they establish a new test session and open a file of class test parameters—configurable test settings that apply to a specific class—from a .ctp file (among other tasks). Test menu items start/stop static and dynamic analysis tests. View menu items display information related to the current test, such as class test parameters. Preferences menu items let you customize Jtest settings, such as choosing whether the default testing UI should be the Class Testing UI or the Project Testing UI. Tools menu items access Jtest's tools, such as a tool for finding classes. The sole Window menu item lets you access the Project Testing UI. Finally, Help menu items present help information, such as the Jtest user's guide and tutorial.
  • Toolbar: Situated below the menu bar, the toolbar offers shortcuts to commonly accessed menu items, such as Start A New Test Session, Start All Tests, Open the Project Testing UI, View Test Results, and Activate Context-Sensitive Help.
  • Class Name panel: The Class Name panel appears below the toolbar and lets you choose a classfile to test. Either enter the fully qualified classfile name (without the .class extension) in the text field or click the Browse button and use the resulting dialog box to select the appropriate classfile.
  • Test Progress panel: The progress of various tests appears on a Test Progress panel, located below the Class Name panel. By default, this panel is minimized.
  • Errors Found panel: Below the Test Progress panel is an Errors Found panel that displays all discovered errors in four sections: Static Analysis Violations, Design by Contract Violations, Uncaught Runtime Exceptions, and Specification and Regression Errors (I discuss Design by Contract later). The latter three sections deal with dynamic analysis.
  • Status bar: The status bar presents the location and name of the current class test parameters file, as well as a visual indication that testing is in progress.


Figure 1 illustrates the various GUI (graphical user interface) elements that compose the Class Testing UI.

  • Print
  • Feedback

Resources