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
additional resources
White Paper - How to Improve Delivery of Advanced Web Applications

White Paper

Virtual Workforce: The Key to Expanding The Business While Cutting Costs

Get the independent advice and expertise you need to support a virtual workforce.

Go inside:
The three-step approach to making a virtual workforce a reality.
The four flavors of client virtualization technologies.
The three key initiatives that solve IT challenges.
Download now »
White Paper: Successfully Secure Your Wireless LAN With Wi-Fi firewalls.

White Paper

Addressing Linux Threats Leveraging Fewer Resources

The increase in Linux popularity has increased the frequency and sophistication of malware attacks. Read this 2 page white paper now to learn how you can protect your Linux environment with real-time protection that is certified by all major Linux vendors.

Download now »
White Paper - The 2009 Handbook of Application Delivery

White Paper

The 2009 Handbook of Application Delivery

Ensuring acceptable application delivery will become even more difficult over the next few years. As a result, IT organizations need to ensure that the approach that they take to resolving the current application delivery challenges can scale to support the emerging challenges. This handbook elaborates on the key tasks associated with planning, optimization, management and control and provides decision criteria to help IT organizations choose appropriate solutions.

Download now »
White Paper - Is Your Backup System Outdated?

White Paper

Mid-range Storage Considerations

A common misconception is that mid-range storage requirements are dramatically different than that of a larger enterprise. Mid-range storage users may require less capacity, but they have similar functionality and management requirements. This ESG paper examines mid-range storage needs and reviews a new solution that adjusts size while retaining value, performance and functionality.

Download now »

Developer World Newsletter

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

©1994-2010 Infoworld, Inc.