Writing automated tests is a critical step in software development. A quality, automated testing suite provides rapid feedback to make sure a change meets requirements and also provides a valuable safety net so that a regression isn’t accidentally introduced. Automated testing also enables devops practices like Continuous Integration and Continuous Delivery, greatly increasing the speed and ease with which changes can be pushed to production.

In this article we will look at five frameworks that help improve the process of automated testing. These frameworks can help with writing tests for complicated use cases, improve readability, and improve reliability.

AssertJ

Automated tests serves as a form of “living documentation” for the system under test. Like any documentation, it is only useful if it accurately communicates the key concepts to the reader. AssertJ helps improve the readability of automated tests by creating a fluent assertion syntax. In AssertJ all assertions start with assertThat(actual). Which replaces for example, the sometimes confusing JUnit assertEquals(expected, actual) with assertThat(actual).isEqualTo(expected).

AssertJ is fully compatible with all versions of TestNG and JUnit, so you can start using AssertJ in your next tests without having to worry about a complex migration process.

JUnit 5 Logo

JUnit5

JUnit5 was released nearly three years ago and now is as good as time as any to switch to the newest version of the popular testing framework! JUnit 5 introduces many improvements to the JUnit framework including:

  • Java 8 support (JUnit 5 requires at least Java 8)
  • Improved extensibility
  • New Extensions API
  • Improved parallel testing support
  • Ordered testing support
  • Backwards compatibility to JUnit 3.8
  • and much more

I have covered JUnit 5 extensively in the past, and have a github repo available with examples on how to use JUnit 5’s new features which can be found here: https://github.com/wkorando/welcome-to-junit5-v2

Mockito Logo

#continuous delivery #frameworks #readability #reliability

Five Java frameworks for improving your automated testing
1.05 GEEK