December 12, 2003

Jtest promotes good Java hygiene

Combination of debugging and testing tools keeps your Java code squeaky-clean

Parasoft's Jtest is a combination static-code analysis tool and souped-up JUnit-style unit testing environment for Java. Its primary raison d'etre is to eliminate bugs so you don't have to chase them down with a debugger. Its secondary use is as a regression testing tool, and this mixture of testing capabilities makes a powerful alloy.

Jtest automates two broad categories of testing: static and dynamic. The former is more properly called static analysis and involves examining your code for errors in syntax, style, standard, and usage, and other characteristics. Static analysis is driven by Jtest's library of rules, of which there are two general kinds: those that apply to specific Java constructs (such as EJBs or servlets) and those that apply to generic Java code (such as metrics or formatting). Jtest also allows you to create custom rules for enforcing coding guidelines specific to your company.

Jtest examines your code’s generated class file, and – from the information it gathers – performs global static analysis to catch “soft errors” and poor coding practices, such as class fields that are never accessed.

Jtest’s dynamic testing includes automatic generation of white-box and black-box test code. The product can generate white-box tests because it examines code directly. Jtest looks at your code, creates tests that might generate uncaught exceptions, and unleashes those tests, logging any exceptions and errors for later examination.

Black box testing verifies that code functions according to specification. A black box test knows nothing about the internals of the code, only that if you pass a method a specific set of inputs, the method should return a specific output.

Jtest’s black-box test-case generation is guided by DbC (Design by Contract), a well-defined syntax for comments that describe a method’s inputs and outputs and -- to some degree -- specify important expectations that the method and its caller can count on. For example, a DbC entry might define that a particular method take a reference to an array as input, and specify that the reference cannot be a null pointer. Jtest examines each method's DbC information and constructs JUnit-style black-box test cases.

Test-case-generating capabilities are reasonably elaborate in Jtest. For example, if a method takes a complex object as an input parameter (provided that the class definition for the object is in the class path), Jtest will create test cases that do their best to construct test objects for the particular method. Also, Jtest automatically generates stubs for external code or code that employs a resource unavailable at test time. If a method being tested relies on data read from a file, Jtest will create stub code that simulates the read operation so the test can be completed.

The version of Jtest I examined arrived integrated with the Eclipse development framework, but other versions plug into Borland's JBuilder and Together ControlCenter, IBM's VisualAge, IBM's WSAD  (WebSphere Studio Application Developer), and Sun ONE Studio.

When you run the Eclipse-integrated version of Jtest against your source code, the tool performs static and dynamic testing in a single swoop, automatically generating and executing test cases (and any required stubs). All errors are then collected in the log window.

Close

On Twitter now

Application development

Powered by Twitter

White Paper

D2D Virtual Tape Library Replication Primer

This whitepaper explains the terminology and concepts behind Data Replication technologies and establishes some sizing rules through worked examples. Learn the new paradigm in disaster tolerance—protect data anywhere.

Download now »

White Paper

An Alternative to Virtualization for Datacenter Cost Savings

Server virtualization is a popular option for dealing with mounting datacenter costs. Another equally promising approach is the use of an Application Delivery Controller. Citrix NetScaler provides a low-cost way for organizations to reduce their server count and accrue cost savings from a reduction in space, cooling, power and personnel.

Download now »

White Paper

Why Your Firewall, VPN, and IEEE 802.11i Aren't Enough to Protect Your Network

The emergence of WLANs has created a new breed of security threats to enterprise networks.

Included in HP ProCurve WLAN solutions is security technology that alleviates threats from WLANs through:
* Monitoring wireless activity inside and out of the enterprise
* Classifying WLAN transmissions into harmful and harmless
* Preventing transmissions that pose a security threat to the enterprise network
* Locating participating devices for physical remediation

Download now »

White Paper

Bringing the Edge to the Data Center

Effectively address data protection challenges, implementing solutions that help store and protect business–critical data while cutting costs and improving efficiency and reliability.

Download now »

Sign up to receive InfoWorld Resource Alerts

Subscribe to the Developer World Newsletter

Receive a weekly roundup about the art and science of software development.

©1994-2009 Infoworld, Inc.