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.

7
  • 6
    JUnit5 is not yet production ready and only works with java8 minimum. Commented Jul 8, 2016 at 21:00
  • @JulienHerr, y. It also uses workarounds to run itself in compatible way with junit4. Commented Jul 11, 2016 at 9:33
  • no IDE integration plugins yet for JUnit5... Commented Jul 11, 2016 at 9:35
  • It looks you have no reason to do another migration for the moment ;) fyi, IntelliJ should support junit5 really quickly after the GA. Commented Jul 11, 2016 at 20:25
  • 2
    @JulienHerr IDEA already supports JUnit 5. See blog.jetbrains.com/idea/2016/08/using-junit-5-in-intellij-idea Commented Aug 21, 2016 at 15:30

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.