Top 10 Java Test Framework for Automation in 2019

javinpaul on April 09, 2019

Disclosure: This post includes affiliate links; I may receive compensation if you purchase products or services from the different links provided i... [Read Full]
markdown guide
 

Hi, good list of useful tools. One thing you seem to have missed is AssertJ as an alternative assertion library. It’s fluent API is much more readable and versatile than the standard JUnit assertions. I also think it ships as a transitive dependency with spring testing. So you just need to static import the right methods. I’ve never looked back. 😊

 

Thanks for suggestion, is it better than Hamcrest? another similar library which provides fluent assertion methods to read your test like English.

 

Hey, no, Hamcrest is a Matcher Library, AssertJ is an assertion Library, that actually supports Hamcrest matchers and I’m using them as well. It’s a bit complicated... 🤪

Ah I see, I am sure going to try that on my unit tests now. How about mocking, do you use Mockito or PowerMock? I am a big mockito fan but I always stuck with mocking static fields like Logger in some Java classes.

Definitely Mockito. If you need to use PowerMock you’re probably doing something wrong. Why would you ever need to mock the logger?

 

Great article! 👍

You may also want to check out recheck-web (disclaimer: I'm a contributor). It is a library for Golden Master Testing of web apps, respectively, their UIs, which replaces traditional assertions.

(Also happy to get your feedback.)

 

Nice one @daniel , will take a look, does it complements Selenium or alternative of that?

 

It complements Selenium in terms of assertions and locators. Oh, and did I mention it is open source? 😊

That's awesome, it's now on my TODO list to check :-) Once again thanks for suggesting it.

 

Nice collection of testing tools!

May I suggest an addition to your list?

You might want to take a look at Citrus, an integration testing framework for various message protocols and data formats.
It supports HTTP REST, JMS, Kafka, SOAP, FTP, SSH, XML, JSON and much more, so it's possible to test you application / microservice fully isolated!

 

Thank you @Simon Hofmann, I'll sure take a look, looks intereting :-)

 

From what little I've seen, the executable Cumcumber/Gherkin style API testing specifications of the Karate testing framework (by Intuit, of 'Quickbooks' fame) look amazing, actually. Quoting them:

If you are familiar with Cucumber / Gherkin, the big difference here is that you don’t need to write extra “glue” code or Java “step definitions” !

The idea is, you use a VERY extended Gherkin syntax (Given-When-Then) specification definition to avoid having to write test code (although Karate does integrate with JUnit, so as to be runnable from an IDE etc.). This means that non-programmers and product owners can concretely define JSON/XML-based payloads, specify endpoint URL's, HTTP verbs and write test validation matchers, again interrogating JSON/XML/etc. return types, all from the specification script, thus:

Feature: simple example of a karate test => https://github.com/intuit/karate/blob/master/karate-netty/src/test/java/com/intuit/karate/mock/hello-world.feature

Background:
# to test that expressions also work for the method keyword
* def postMethod = 'post'
* def getMethod = 'get'

Scenario: create and retrieve a cat

Given url mockServerUrl + 'cats'
And request { name: 'Billie' }
When method postMethod
Then status 201
And match response == { id: '#ignore', name: 'Billie' }
# And assert responseTime < 1000

Given path response.id
When method getMethod
Then status 200
 

Nice article! Thank you very much for the good test info!

 
code of conduct - report abuse