JUnit 5 vs TestNG

Sergii picture Sergii · Jul 8, 2016 · Viewed 10.1k times · Source

We were using JUnit 4, but we had some problems with test grouping. For integration tests we had problems with running order. We had migrated to TestNG in February 2016.

Now we are starting a new independent module for our project and part of our team players wants JUnit 5. I believe it is much better than 4th (there are some new important features, but I see some problems too).

I do not want to use JUnit 5 because of fear of possible problems in our new application, because I have experience with 4th. But I have to be more flexible for the team, so before making a decision I need recommendations from users who have experience with JUnit 5.

Answer

Andrii Abramov picture Andrii Abramov · Jan 6, 2017

JUnit 5 has introduced a lot of new features. Currently Intellij IDEA supports JUnit 5.

Take a look at article about integrating: Using JUnit 5 in IntelliJ IDEA.

There are some useful annotations now, like:

  • @Tag Used to declare tags for filtering tests, either at the class or method level; analogous to test groups in TestNG or Categories in JUnit 4

  • @DisplayName Declares a custom display name for the test class or test method

See more: JUnit 5 User Guide