25

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.

Maëlan
  • 3,586
  • 1
  • 15
  • 35
Sergii
  • 7,044
  • 14
  • 58
  • 116
  • 6
    JUnit5 is not yet production ready and only works with java8 minimum. – juherr Jul 08 '16 at 21:00
  • @JulienHerr, y. It also uses workarounds to run itself in compatible way with _junit4_. – Sergii Jul 11 '16 at 09:33
  • no IDE integration plugins yet for _JUnit5_... – Sergii Jul 11 '16 at 09:35
  • It looks you have no reason to do another migration for the moment ;) fyi, IntelliJ should support junit5 really quickly after the GA. – juherr Jul 11 '16 at 20:25
  • 2
    @JulienHerr IDEA already supports JUnit 5. See https://blog.jetbrains.com/idea/2016/08/using-junit-5-in-intellij-idea/ – NamshubWriter Aug 21 '16 at 15:30
  • Does `TestNG` give you everything you need? If yes, then stick with it. JUnit 5 still "Work In Progress" and does not support some features of JUnit 4 yet. – Alexei Osipov Sep 29 '17 at 16:27
  • Yes it does, I think. But not i do not care about test framework, we have started new project and we are using unit tests only, for integration tests we use separate project. It solves our issues – Sergii Sep 29 '17 at 16:42

2 Answers2

11

TestNG objective is beyond unit test so it covers wider testing needs like Scenario Tests, Integration Test, Dependency Test, Ordering, Parallel Execution etc, but these feature are not supported in JUnit 5.

The JUnit 5 team have these above items in their road map, but they are extending a unit testing framework to support wider range of testing needs. Lets see how the new subsequent release of Junit 5 is able to address the wider testing need in comparison with TestNG

For Spring based application Junit fits best for doing the Unit and Integration Testing as it the default testing framework and Spring Provides lots of Test API with Mockito.

For general testing and Web Automation (Selenium) - TestNG is the de facto.

Anver Sadhat
  • 3,074
  • 1
  • 25
  • 26
10

JUnit 5 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

Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96
  • Also *Eclipse 4.7 Oxygen* now support *JUnit 5* through the *JUnit 5 Support (BETA) for Oxygen 4.7* plugin that can be installed in the marketplace. – Phoenix Aug 28 '17 at 15:58