Static Analysis

Subscribe to Static Analysis: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Static Analysis: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Static Analysis Authors: AppDynamics Blog, Jason Bloomberg, RealWire News Distribution, Skytap Blog, Jayaram Krishnaswamy

Related Topics: Static Analysis

Static Analysis: Article

Jtest 5.0 from Parasoft

A solution to the need for unit testing

Most developers would agree that software development is not as daunting a task as is efficient software development. We have seen teams that can design and develop software - and with automated development tools, IDEs as they are called, the software development process has become a lot easier. But while an architect can always come up with a design and a development team can write the code for a given design, there aren't many developers who can write the best possible code for a given design - especially in the case of distributed application development, in which multiple teams are working on modules of a given application.

How can you ensure that what comes out of these multiple teams is coherent and that it will work? This is where the need for software testing tools comes in. Testing tools not only help you detect errors in code, they can help you implement coding standards. This is one of the reasons behind the growing popularity of automated testing tools in the IT industry. These tools ensure that many basic software testing tasks are automated, resulting in more efficient and quicker development. Amazing, isn't it? But with more than 40 different testing tools, deciding which to use is enough to cause headaches for most software managers.

Parasoft Jtest was one of the first products to receive the Ready for WebSphere validation from IBM, which means it meets all the requirements for easy integration with IBM WebSphere Studio. With WebSphere Studio, developers can use Jtest for error prevention, perform black-box and white-box testing, and also do static analysis of Java code on WebSphere.

During the process of reviewing Jtest version 5.0 I looked at and evaluated some of its important features - including installation and integration with WebSphere Studio, coding-standard enforcement, automated unit testing, and use of the product in a team environment.

Ease of Installation and Integration with WebSphere Studio
The Jtest plug-in for WebSphere Studio 5.1 (and for all IDEs based on Eclipse 2.x) is available for download from the Parasoft Web site (www.parasoft.com), in the "Downloads" section. Note that you must register and provide an e-mail address linked to a valid company. Parasoft doesn't accept e-mail addresses like [email protected] or [email protected]. Once you are registered and logged in to the Web site, select the product and platform to download.

Installation
The installation of the Jtest plug-in for WebSphere Studio is very simple and intuitive. You are asked to select a directory for installing the Jtest extension files. The default is C:\Program Files\Parasoft\JtestExtension. You are required to point to your WebSphere Studio (or Eclipse) installation directory. Be sure that WebSphere Studio isn't running before you start the installation process.

User Interface
The Jtest user interface is straightforward and easily blends into the WebSphere Studio 5.1 (Eclipse) user interface. It is also accessible as one of the perspectives of WebSphere Studio 5.1. You no longer need to open a separate software/user interface to use Jtest. Everything required for using Jtest is accessible via your WebSphere Studio perspectives, which reduces the learning curve. To start using Jtest, open the Jtest Perspective in WebSphere Studio, browse to your class, select it, click the "Play" button on the toolbar, and zoom - you've already run a test. The Jtest summary panel displays all the required information about the test, such as the number of files checked, number of errors found, etc. The errors are shown in the Errors Found view.

One of the main features of Jtest that I looked at was the enforcement of coding standards. Implementing coding standards for your team can require overwhelming effort - the lack of which can result in delayed product schedules. Developing coding standards and then ensuring that each developer adheres to them can be a very cumbersome and practically impossible task. However, Jtest helps you automate the entire task of implementing coding standards. Jtest implements strict checks to test each class for as many as 380 coding standards/rules. Using such rules can help you eliminate possible errors and issues related to threading, garbage collection, memory leaks, etc. In addition to using built-in rules, Jtest allows you to write your own custom rules and include them to be checked by Jtest.

Jtest allows you to select from some of the most popular coding standard options, including "Code Conventions for the Java Programming Language," by Sun; Effective Java, by Joshua Bloch (one of my favorites); Parasoft's recommended rules, and "Writing Robust Java Code," by Ambysoft.

Using the Jtest GUI (see Figure 1) you can select a Parasoft Jtest configuration (see Figure 2) wherein you can choose the coding standards you want to follow. It could be any one of the above-mentioned industry-accepted coding standards, or it can be a mix. When I tried to create a custom mix from two coding standards I found that Jtest has no documentation about that, but the Jtest support team was quick in getting back to me with a well-documented solution about how to handle that!

 

 

Parasoft provides a description for each coding rule, or standard, that helps you understand the importance of the rule, how your code violates the given rule, and the effects doing so. It also gives you a choice to have Jtest automatically fix the coding standard/rules violation for you. Neat!

Automated Unit Testing Using Jtest
Unit testing with the help of Jtest helps you confirm whether the code is working as it is supposed to. It enables seamless white-box testing for your projects, thereby helping you confirm the structural strength of your Java code. Jtest extends the power of JUnit and allows you to completely automate the unit testing of your projects. It does so by enabling automatic generation of JUnit test cases and test-case execution.

It also allows you to do functional testing (also known as black-box testing) for your projects. Functional testing ensures that your applications work as they are supposed to, or as the users would expect them to. This can be very useful in confirming whether the user requirements have been properly captured, as black-box testing tests the software from an end user's perspective. This is done at the level of the smallest functional unit, and thereby the possible bugs or glitches in properly capturing user requirements are brought to notice much earlier in the process.

Jtest also helps you regression test your software and tracks all the changes to the code, maintaining a properly integrated and updated code base. This can be useful to identify whether the modified code has generated new errors. In large projects, regression testing is usually performed in nightly builds so that in the morning when the team comes back to their desks they have the error reports ready to work on, which saves valuable project time.

Detecting Memory Leaks Using Jtest
Jtest 5.0 monitors the object allocate events and object free events during the execution of a unit test. By comparing the objects free versus the objects allocated, you can easily determine if there are any unreferenced objects living in the memory. In addition, because each test is executed three times, Jtest ensures that the leaked memory is not for initialization or cache. To detect memory leaks using Jtest you need to go to Execution > Options > and enable the "Detect memory leaks" check box. I won't say that Jtest will discover every possible memory leak, but it certainly allows those arising from poor programming to be easily caught and rectified.

Using Jtest in a Team Environment
A product that works well for one workstation but that isn't designed for team usage is of little help when it comes to team development. These days most IT projects involve a team of developers - and the product you use for automated unit testing must support a team environment. Jtest can be implemented across a team of developers/testers to help improve the quality of the code and, finally, the application, especially with the use of supportive products like the Group Reporting System and Team Server, both from Parasoft.

Parasoft has developed a recommended workflow that helps teams effectively use the automated error-prevention features Jtest offers. Builds occur on a nightly basis, and reports are generated and sent out to individual or group mailboxes every morning. Jtest offers batch testing facilities using the Jtest CLI (jtestcli.exe) that is in the Jtest installation directory.

However, to implement this, an ideal configuration would include one Jtest installation with a CLI license (the default Jtest license doesn't support the command-line interface or the batch mode), an installation of Jtest on each developer workstation, and an installation of Parasoft's Group Reporting System and Team Server.

Developers will have to use their Jtest configurations to test the code they write, and then check the code in the team's source-control system. Each night the Jtest CLI will run on the build machine (pulling the source code from the source-control system), generate test cases, check the code strength, and store the results in the Group Reporting System. It can also mail out the reports generated to each developer (or a set of e-mail groups). The developer workstations will point to the Team Server, where they can access the Jtest configurations, coding rules, test cases, etc., to be used by the team. The Team Server is a single point of access for developers to get any updates that occur to the configurations, coding rules, etc.

Jtest is currently available with a price tag of $3,495 for one user (North American Users only). While this may not be an issue for a small team, for large teams you might want to have several testers with Jtest installations who can run tests for the rest of the team. I believe that Jtest should start offering some sort of team license, as it may difficult for an organization with a large team to implement Jtest on each developer's machine. During my last conversation with Parasoft, I was told that they plan to unveil a new licensing model to promote team adoption of Jtest in Q1, so you can check the Parasoft Web site for more information.

COMPANY INFO
Parasoft
101 E. Huntington Dr.
Monrovia, CA 91016
Phone: 626 256.3680
Web: www.parasoft.com
E-mail: [email protected]

PLATFORMS
Windows NT/2000/XP, Linux for X86 (glibc 2.1+), or Solaris for Sparc

The stand-alone version of Jtest can run without an IDE on any Pentium-based computer and can be used for its automatic error-prevention and other features. However, the Jtest plug-in requires WebSphere Studio 5.1 to be installed (which means Eclipse 2.1 and JRE 1.3 should be available).

PRICING
Jtest is currently available with a price tag of $3,495 for one user (North American users only).

Conclusion
As an automated testing solution, Jtest passes the tests with flying colors. It helps you implement the industry-standard best practices during the development phase, allowing you to detect and eliminate coding errors and thereby reduce development time and cost, leveraging existing source-control systems. It installs quickly, integrates well with WebSphere Studio, and performs well! What's more, with a promise to improve upon the current features and add more, Jtest seems to be an ideal testing solution for development teams.

More Stories By Bhavesh Patel

Bhavesh Patel, an enterprise architect with Noospherics Technologies, has over 10 years of IT experience and holds certifications from IBM, Microsoft, Compaq, and Sun. Bhavesh, who speaks and writes on WebSphere topics, has worked as a project mentor, tech lead, and WebSphere administrator for several major telecommunications and financial companies, and for the U.S. government and military.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.