Start of main content

JUnit, high five! Migrating to JUnit 5 Extensions

Language -RU

In his talk on this Heisenbug, Dmitry talks about how with just 4 classes you can make your tests look nice and idomatic. But a separate big topic about how to improve the look of your tests is the features that JUnit5 provides. (Briefly, Dmitry refers to this report in his today's.) Dmitry talked about this in 2018, and his report has not lost relevance.

JUnit 5 is a totally new framework, its first release candidate has been issued less than one year ago. JUnit name demands a lot, as it is the most popular solution for writing tests in Java-world, fresh version of which has been wanted for more than 3 years. What did we get? Totally new coding base, architecture and API in the combination with the simple and impressive previous version.

Migration process from the version 4 is easy — you can limit it by simple annotations replacement. But here at PropellerAds, while migrating to the JUnit 5, we first tried to answer the question — how to use new API to make our testing better?

To make the long story short:

  • if your functional tests are written in AAA style (Arrange — Act — Assert), and the section of data preparation is more complex than Calculator calculator = new Calculator();
  • if you write tests for "complex" web-projects, such as: internet banking, documentation systems, CRM and etc., also creating a lot of "domain" objects for simple test-case;
  • if you want to provide really Simple API to make it possible for the newbie to spread testing coverage in your project without being shocked by the class with tests, then…

This talk is 100% for you! Using real-life examples, we'll show you how we didn`t just replace the annotations but got rid of the first "A" in the "AAA" abbreviation.

Speakers