Testing, testing! This integral part of the development process is often given short shrift. Today, we’re taking a look at five of our favorite open source Java testing tools for unit tests, requirement tests, automated UI tests, and more!
No one wants to take a test. It’s the best part about being done with the education system – no more cramming for finals! But, sending software out into the world without a bit of testing is just asking for trouble. So, today we’re taking a look at five of our favorite Java testing tools.
Picking a particular testing tool can be difficult – there are so many open source options out there! Instead, you need to focus on what exactly needs testing and then go from there.
Caveat: As always, this list is subjective. We don’t have all day to go over every specific Java testing tool out there. Your experience will be different from mine, but we’re all just trying to make our code work and our apps shippable.
In no particular order, here are the top 5 testing tools for Java.
JUnit
No big surprise here! If you’re looking for a unit test, Junit is your best bet! We’re big fans of this popular testing framework. JUnit 4 is still a popular option for developers not looking to switch it up, but we recommend JUnit 5. Deemed to have “the potential to redefine testing on the JVM”, JUnit 5 consisted of three different modules: JUnit Platform, JUnit Jupiter, and JUnit Vintage. JUnit just released version 5.4 last month, with all kinds of shiny new features and tools for developers.
The JUnit platform provides developers with an advanced testing framework for unit tests, among others. It supports a number of popular IDEs and build tools like IntelliJ IDEA, Eclipse, NetBeans, Gradle, Maven, and more, making it compatible with any set up you might be running. (Plus, it even works with a bunch of other languages, but don’t tell Java that!)
More information about JUnit is available here!
TestNG
TestNG is another popular unit testing tool for Java developers, but it covers all kinds of tests. It’s a powerful test framework that enables developers to write flexible tests with grouping, sequencing, and data-driven features. Plus, it even makes writing parallel tests easy.
Inspired by JUNIT, TestNG has a number of functionalities that make it even more capable, with things like annotations, flexible test configuration, parameters, and support for data-driven testing. TestNG even comes with support for Eclipse, IntelliJ IDEA, and NetBeans.
Selenium
Looking for an automated UI test? Selenium has got you covered. This suite of tools helps developers automate web browsers across many platforms for testing purposes. Test your Java pages without even launching them! You can also test web applications and write web application acceptance tests.
The Selenium IDE is a Chrome and Firefox add-on that will do simple record-and-playback of interactions with the browser. It’s perfect for creating quick bug reproduction scripts or writing scripts to help automation-aided exploratory testing. It’s an easy to use IDE with simpler test debugging and cross-browser execution.
Apache JMeter
The Apache JMeter tool is a 100% pure Java application. Designed to load test functional behavior and measure performance, it was originally meant for just testing web apps but has expanded its purview to all kinds of test functions. Helpfully, JMeter allows developers to test performance for both static and dynamic resources for dynamic web apps.
JMeter can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. Other features include a fully featured Test IDE, CLI mode, caching, a dynamic HTML report, and a highly extensible core.
FitNesse
FitNesse is a new tool to us here at JAXenter. It’s a wiki web server to focuses on requirements and acceptance testing. The barrier to entry is quite low, since it is a wiki meant for collaboration. The wiki pages created in FitNesse are run as tests. The specifications can be tested against the application itself, resulting in a roundtrip between specifications and implementation.
FitNesse automated acceptance tests are power tools for fixing a broken requirements process. (Check out the Two Minute Example here.) These tests give back feature feedback early and often. They’re also deterministic, helping developers successively refine their projects.
Honorable mentions
It’s not a JAXenter list without a few honorable mentions. If you’re looking for a mocking framework, Mockitois a popular unit testing tool that helps developers write clean, loosely-coupled code. The Grinder is a load testing framework that makes it easy to run a distributed test using many load injector machines. And, last but never least, Spring MVC comes with its own testing framework with libraries for writing automated tests for Spring apps.
Let us know if we missed one of your favorites in the comments below! Study hard and good luck with those tests!
[“source=jaxenter”]