JUnit 5 tutorial, part 1: Unit testing with JUnit 5, Mockito, and Hamcrest

See the original posting on JavaWorld

JUnit 5 is the new de facto standard for developing unit tests in Java. This newest version has left behind the constraints of Java 5 and integrated many features from Java 8, most notably support for lambda expressions.

In this first half of a two-part introduction to JUnit 5, you’ll get started with testing with JUnit 5. I’ll show you how to configure a Maven project to use JUnit 5, how to write tests using the @Test and @ParameterizedTest annotations, and how to work with the new lifecycle annotations in JUnit 5. You’ll also see a brief example of using filter tags, and I’ll show you how to integrate JUnit 5 with a third-party assertions library—in this case, Hamcrest. Finally, you’ll get a quick, tutorial introduction to integrating JUnit 5 with Mockito, so that you can write more robust unit tests for complex, real-world systems.

To read this article in full, please click here