Top 25 Tools for Automated Testing of JAVA Applications (Part 3)

In this article, we will see an overview of component wise automated testing tools for JAVA/J2EE applications. Most of the popular tools are open source and are largely derived from JUnit. The tools vary for view, business logic and validation components.

This is 3rd and the last article in JAVA/J2EE testing article series. Check out first two articles here: How to test JAVA applications and Getting started with automation testing of JAVA applications.

Comprehensive List of java automated testing tools

JAVA application testing tools

JavaScript/JQuery/AngularJS (Validation for the view component)

Java Script/JQuery is generally used for validation of the view component such as JSP or JSF.

Here are some of the important tools for testing Java Script:

#1) JSUnit is an open source Unit testing framework for JavaScript. If you are familiar with JUnit, then you will have no difficulty learning JSUnit. It is an extension of JUnit for JavaScript testing. JSUnit is no longer supported, however. The developers of this framework switched to the development of Jasmine framework. For more information check this page.

#2) Jasmine is an open source Unit Testing framework for JavaScript. It is based on other unit testing frameworks such as RSpec, JSpec, JSSpect and Screwunit. Jasmine is a BDD (Behaviour Driven Development) for JavaScript and is popularly used to test AngularJS applications.

Jasmine contains two blocks – the describe block and the it block. Test cases with similar functionality are grouped together using the describe block, and the it block contains the individual test cases. For more, please refer this page.

Testing through Jasmine can be very simple, as the test cases are similar to written English. Here is a sample:

JavaScript Function:

function sayHi()
{
return "Hi!";
}

A Jasmine test case would look like this:

describe("Say Hi", function() 
{
 it("return hi", function() 
{
 expect(sayHi ()).toEqual("Hi!");
});
});

#3) Karma is essentially a Unit Testing tool for Angular JS applications [Angular JS is a JavaScript framework and is maintained by Google]. Karma is also maintained by the Angular JS team at Google. Karma runs the test cases from the configuration file karms.conf.js and displays the results to the user via the command prompt. For more information, please refer this page.

#4) Qunit is a JQuery Unit testing framework developed by the JQuery team. However, QUnit can also be used to test regular JavaScript code. Understanding Qunit is very simple, and the results are displayed in a screen which is easy to understand and interpret. For more, please check here.

There are several other Unit testing tools for JavaScript such as FireUnit, RhinoUnit, TestSwarm, BrowserSwarm, Mocha, Chai, and Sinon.

JSP (JAVA Server Pages – The View Component)

Once run, JSP is converted to a Servlet. A Servlet is a Java class. You may wonder whether JUnit can be used to test JSP? From the design point of view and with the use of frameworks, JSPs currently do not contain much java code.

Therefore, it is preferred to cover JSPs in functional or Integration testing, though Unit testing could also be performed. JSPs are tightly coupled to the Servlet container and the tester needs to generate request and response if tested separately. TagUnit can be used to test the taglibs within the JSP Pages. Other frameworks to test JSPs are listed below.

#1) TagUnit

JSP tags are either built-in or user-defined tag elements that help remove a lot of work from JSP to separate reusable components. The functionality of Tags is written in Java classes and can be used within the JSP as any other tag.

They cannot be tested directly with the help of JUnit, as they are not standalone classes, meaning the tag classes are called only when a JSP is converted to Servlet. For more, please check here.

Here is sample built-in code tag:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
<title </title>
</head>
<body>
<c:forEach var="countvar" begin="1" end="4">
Count <c:out value="${countvar}"/><p>
</c:forEach>
</body>
</html>

TagUnit provides are screen to display the results. First, it checks whether the tags have relevant handlers and getter setter methods. Below is a sample TagUnit test case:

<tagunit:assertEquals name="Count">
<tagunit:actualResult> <c:forEach var="countvar" items="1,2,3,4"> <c:out value="${countvar}"/></c:forEach> </tagunit:actualResult>
<tagunit:expectedResult>1234</tagunit:expectedResult>
</tagunit:assertEquals>

#2) Tagit is another useful tool to test JavaScript, JQuery and JSP Custom tags. For more, please check here.

#3) Cactus was another Unit testing framework for testing Servlet, EJBs and JSP tags for Jakarta projects. It has been retired and is no longer supported.

#4) Selenium WebDriver is an open source testing tool for Web applications. WebDriver simulates the user action on the web and can be used with different browsers such as Mozilla Firefox, Internet Explorer, Safari, Chrome and others. Check here for the link to the official site.

Also read => For more on WebDriver, please refer to our article within this link.

#5) JSPUnit is an extension of JUnit for Unit testing JSPs. For more, please check here.

#6) HTMLUnit is an open source library and a headless browser. HTMLUnit emulates browser behavior and therefore is extensively used for Integration testing. JSPs are designed to run inside the web container and are converted to Servlet when the Web Server runs, but HTMLUnit could be used to test the View part even without the container.

For testing, JSPs are first manually converted to Servlet class with the help of Jasper. With the container not running, one needs to simulate the request and response behavior. This is done by creating Mock objects of JSPWriter, PageContext, HTTPServletRequest and HTTPServletResponse. For more, please check here.

------------

JSF (JAVA Server Faces – The View Component)

JSF is a web-based framework for UI (User Interface) development. UI could be easily created from a set of standard reusable components. Like Struts, JSF also is a MVC-based framework which contains a Servlet, XML, Bean and JSF Tags.

#11) JSFUnit from JBoss community is a powerful tool for both Unit and Integration testing. It helps in testing both the view component and the server side component. Apart from testing the User screen navigation, JSFUnit can also be used to test the bean and Servlet components for the framework. For more, please check here.

#2) HTMLUnit as seen above is also extensively used for Integration testing of applications where the view part is development with JSF framework. For more, please check here.

JUnit can also be used to test the Java classes of the JSF framework. Tools such as FacesTester can be used for out of the container Unit testing of JSF based applications. Apache Myfaces, which maintains Java Server Faces implementation, also provides a test framework for JSF.

XML (Extensible Markup Language)

#1) XMLUnit is an extension of JUnit, which performs validations of the XML structure and comparisons of contents between the actual and expected XML. For more, please check here.

Servlet, Bean and JAVA Classes (JAVA Classes for Controller and Business Logic)

#1) Servlets are java classes that run on a Web or Application server and are used for handling request and response from the view (JSP/JSF) component. Bean is a Java class that encapsulates several java objects into one, and the Bean is passed around to other classes or components.

There are several other Java classes that are used in an application; some may connect to a database and others may contain business logic.

#2) JUnit is one of the most popular frameworks used for Unit testing Java classes. For detailed information on JUnit please refer to our articles here.

#3) Arquillian is a very powerful tool for Integration and Functional testing of Java middleware. It is most frequently used with the build tool Maven and on top of Unit Testing framework such as JUnit and TestNG. It frees the tester from creating Mock objects. Arquillian can be used to test JSF, EJB, Servlets and other Java classes. For more, please check here.

#4) ServletUnit is a framework specifically for testing Servlets by creating request and response objects. If the Servlet contains only simple code, then Unit testing can be performed with JUnit. For complex applications, if the testing needs to be performed in a simulated Servlet container, then ServletUnit can be used. For more, please check here.

#5) Mock objects are mostly used for Unit Testing. They help in testing the interactions between the objects in an application. If you have Objects in your application that you would like to test, and if those objects depend on other objects, you can mock the dependency instead of running and creating a real object.

This enables testing for each object in detail and in isolation. Some popular mock frameworks include Mockito, JMock, JMockit, EasyMock, and PowerMock.

EJB (Enterprise JAVA Bean)

An EJB is a Java component in an application that usually contains Business Logic. For EJB based projects, JUnitEE could be used, though JUnit is still the popular choice.

#1) JUnitEE is an extension of JUnit, which runs directly in the same application server as the project. JUnitEE provides three Servlets, which call the regular JUnit test cases. For more information check here  or here.

SWING

Swing is a set of libraries in Java to create rich Graphical User Interface. UISpec4J, Abbot, Fest, and QF-Test are a few of the most popular Unit testing frameworks that can be used for Swing based applications.

Functional Testing

#1) HTTPUnit is a Functional testing framework based on JUnit, though it can be used for Unit Testing. It emulates browser behavior such as Form Submission, Page redirection, JS Validation and cookie management, to name a few. HTTPUnit simulates browser’s GET and POST request. For more, please check here.

#2) JWebUnit is a Java based framework preferred for Functional, Regression and Integration testing. It wraps existing frameworks such as Selenium and HTMLUnit to provide a simple interface for writing test cases. JWebUnit can be used for performing screen navigation testing. For more, please check here.

#3) TestNG is a powerful Java based testing framework for Unit, Integration and Functional testing. It is based on JUnit. TestNG is a strong tool and a strong competitor for JUnit. For more, please check here.

#4) Selenium Webdriver as seen above is another popular Functional and Integration testing tool.

#5) WATIR (Web Application Testing in Ruby) is a powerful web application testing tool developed in Ruby. It requires a tester to have knowledge of the Ruby language, as the functions to perform browser testing are written in Ruby.

The two most important projects are Watir-classic and Water-Webdriver. Watir-classic can drive a web browser automatically unlike other tools which only simulate a browser. Watir webdriver is derived from and a wrapper on Selenium Webdriver. For more, please check here.

#6) TimeShiftX is a test automation software that lets you time travel your applications into the future or past for functional time shift testing. It enables instant time travel without any java code modifications, server manipulations, or domain changes. Safely time travel your custom Java application or any 3rd party java based software such as WebSphere or JBoss. For more, please check here.

JAVA Performance and Load Testing Tools

#1) Apache JMeter is an open source tool for Load and performance testing. If a website needs to be tested for performance, then JMeter sends several requests, collects all the responses, then performs statistical calculations to display the end result in graphical diagrams. For more, please check here.

There are some other good tools like  HP LoadRunner, WAPT, NetBeans profiler, GC Viewer, Patty open source project etc. and the tools we listed on this page can be also used for JAVA based web applications.

Conclusion:

In this article, we have reviewed some of the most popular J2EE component wise testing tools available. In testing J2EE applications, these tools can be used with one another based on the components involved in the applications.

Let us know your experience in automation testing of JAVA based applications.

Recommended reading

3 comments ↓

#1 Dan

for load The Grinder is also a good option.

#2 Umesh patil

thank you for sharing. very detailed list indeed.

#3 Gaurav Khurana

a link which deserves a bookmark. Goot to know there are so many tools existing in the market.

But sometimes it confuses the user to decide upon since so many are there and not one size fits all

Leave a Comment