If you have not done unit testing, you should not consider your code to go for other testing. Unit testing is onus on developer to complete before they ship the code for other Whitebox testing. There are so many frameworks and tools available in the market, I have listed some of the Java unit testing frameworks and tools. Please feel free to comment which one you are using and your opinion about that.
JUnit is a one of the famous Java testing framework written by Erich Gamma and Kent Beck. It is a regression testing framework. Junit helps developer to write test cases so-called white box testing, because the programmer knows the code they can easily write test cases using jUnit. Using class inheritance developer can easily automate the testing.
Cactus is a simple test framework based on JUnit framework for unit testing with server-side Java code.The Cactus framework’s main goal is to use unit testing server-side Java Servlet objects such as HttpServletRequest, HttpServletResponse, HttpSession.
StrutsTestCase is the extension of the Junit TestCase class provides code based on the Struts framework tests. StrutsTestCase provides both Mock objects and Cactus methods used to actually run the Struts ActionServlet, you can run the servlet engine to test. StrutsTestCase uses the ActionServlet controller to test your code You can test the Action object’s implementation, test mappings and forwards declarations. StrutsTestCase does not start the servlet container to test your Struts application but it mock the object, different from the EasyMock. EasyMock provides the API for creating Mock objects, while StrutsTest is dedicated to testing the Mock Object.
JFCUnit enables you to write test cases for the offset Java applications. It is obtained from the code used to open the window and work at component level. It provide unit test for thread programming.
TestNG is based on building a testing framework JUnit and NUnit, TestNG adds many new features that make it more powerful and easier to use, such as:
- Support for JSR 175 annotations (JDK 1.4 JavaDoc comments are also supported)
- Flexible Test configuration
- Support for runtime and logging by default JDK functions
- Powerful execution model (no more TestSuite)
- Support for an independent test method.
JMock is a framework based on TDD, test Java code using mock objects. JMock has the following features: easy to expand, lets you quickly and easily define mock objects, allows you precisely specify the interactions between your objects.
Grinder is an open source Java load-testing framework. it distributed through many load injector.
- Support for performing test scripts Jython scripting engine
- HTTP tests can be managed through the HTTP proxy.
Jetif is a regression testing framework with a pure Java implementation. It’s unit tests and functional tests for Java programs provides a simple and scalable code, you can test for personal development or enterprise-level development. It is easy to use, powerful, and has a number of important features for enterprise-level test. Jetif from JUnit, inspired by JTestCase and TestNG, there are a few basic concepts taken directly from the JUnit, assertion mechanism Test Listener concept, therefore transferring from JUnit to Jetif is very easy.
Unitils is Java open source class Pack designed to make unit test easier and maintainable. Unitils builds on DBUnit and EasyMock project and integrated with JUnit and TestNG. Support for database testing, using mock objects and offers integration with Spring and Hibernate. Unitils is designed with a highly configurable and loosely-coupled way to add these services to the unit test.
P-unit is an open source performance testing framework different from JUnit, JUnit is test the correctness of the code while p-unit not only test code but also check the performance of the test. p-unit records the memory consumption by test case and can generate PDF or image format report of the test. In addition, p-unit also support parameterized tests, multi-threaded testing, and performance comparisons between different Java virtual machine.
XMLUnit provide two JUnit extension classes XMLAssert and XMLTestCase, and set of classes that support jUnit. These classes can be used to compare the differences between two XML, display XML using XSLT, and validate XML. You can evaluated XPath expression value in the XML, traverse a node in XML Lee DOM etc.
Ejb3Unit is used outside the container for EJB3 entity (Entity) and session (Session). Ejb3Unit is a JUnit extension for all JEE or EJB3 projects and create automated standalone JUnit tests. EJb3Unit use a built-in database of memory by default, but you can also specify your own database.
FEST-Swing is a Java Swing GUI application functionality tests, it is an open source class library with user interaction (mouse and keyboard input). Supports most of the Swing components in the JDK. Provides simple, powerful API for creating and maintaining GUI functional tests. Supports HTML embed screenshots of failed GUI tests in the test report. It can be used with JUnit or TestNG.
Ripplet is a powerful, highly reliable, flexible load/stress testing tool. its features include: support for graphic design and can have a clear summary of the load test description. Can effectively control the practical performance load including logic and data flow. Peak makes it easy to diagnose performance bottlenecks. Quickly and accurately assess the actual system under pressure. Allows developers to develop implementation in a live production environment for testing product and produces test reports.
Feed4JUnit can write JUnit parameterized test and provides predefined or random dummy data for these tests. It can create nice CSV or excel file for report. Use Feed4JUnit to easily perform a smoke test with random checksum data to improve code coverage. In addition, Feed4JUnit can be used to easily define the equivalence class testing.
Jubula provides a testing framework for Swing, SWT/RCP/GEF and HTML application for automated functional testing of graphical tools. It is suitable for those who want automate the test. It does not require any coding. support based on Client – Server architecture for distributed test. Items stored in a multi-user database.
18. Citrus – Enterprise SOA Application Based
Citrus is a testing framework for Java development, Enterprise SOA applications based on messages for automated integration testing. Use case testing for Terminal to Terminal, this tool can mimic peripheral systems and agreements various conveyor (for example, JMS, SOAP WebServices, http, TCP/IP, etc.). Citrus provides strong verification mechanisms for XML message content and allows you to build complex testing logic such as: send and receive messages, data validation, automatic retries, variable definitions, dynamic news content, error simulations.
JBehave is a behavior-driven development (BDD:Behaviour-Driven Development) framework. Behavior driven development (BDD) is a test-driven development (TDD) and the evolution of the acceptance of test-driven design is to make these practices more accessible and intuitive.
Some property description of this framework:
- Support for Maven and Ant integration
- Support IDE integration, support in order to run Junit tests
- Support internationalization, can be written in a different language system
- Supports a variety of configurations, Spring configuration, Java Annotation-based configuration, code embedded configuration
20. JCrawler – load testing framework
JCrawler is an open source Web application stress test tool. By its name, you can tell this is a tool like a Web crawler written in Java. As long as you give several of its URL, it can start to climb over, it in a special way to create your Web application load. This tool can be used to test your site search engine-load.
SOme more Java Unit testing Framework by Shahid
Cassandra unit testing CassandraUnit
Cassandra Unit is a Cassandra data operations unit testing framework, it is
similar to relational DBunit database testing framework : https://github.com/jsevellec/c…
XTest – NetBeans IDE Ant Based
XTest is a new testing framework, it was primarily developed for NetBeans IDE. but it can also be used to test other Java products independently. XTest is Ant-based, which means that it allows users to use all the Ant tasks.
UISpec4J – Java Swing Testing
It is dedicated to Swing an open source component unit tests, it is built on JUnit based test suite. UISpec4J makes Java GUI testing very simple.
iValidator - XML based Testing Framework
iValidator is a program based on XML framework for automated testing and integration testing in a complex environment. Its features include: unit test reusability, separation of code and data, offers Eclipse plugin that supports all test levels.
Lattu - Testing Framework for Eclipse
Lattu is a framework for testing Eclipse RCP applications. It is capable of both unit tests and functional tests.
MockCentral – Mocking Object
MockCentral provides a new way to use mock objects to test. Beyond its mock objects defined in your test code it allow developers to create XML files and accessing these mock objects, which can make test cases simple.
JEasyTest – Eclipse IDE Plugin for Mocking
JEasyTest is an Eclipse IDE plug-in mock object frameworks to simplify the use of standard unit test code, such as the use of inheritance.
Jacareto – Capture Playback tool
Jacareto is a capture and playback tools. It allows you to capture the action in your application (like macros). Jacareto can be used for GUI testing, creating a vivid demonstration and analysis of customer behavior.
Thread Weaver – Multithreading Unit Testing in Java
Thread Weaver is a Java framework for writing multithreaded unit tests. It provides a mechanism for creating a breakpoint in your code, when you reach a breakpoint, itstops the thread execution. While
other threads will continue to run. This allows you to write repeatable tests to check the competition, and thread-safe.