GhostCat
GhostCat

Reputation: 140467

Is JUnit5 backward compatible to JUnit4?

I did google quite a bit; but I could neither find a source saying "of course it is" nor one going "no, it isn't; and here it breaks".

We have about 2000 unit tests of very varying quality, using EasyMock, PowerMock, Mockito; and I am simply wondering: is there a reasonable chance that those 2000 testcases just work when switching to JUnit5; or is that so unlikely that I better not spend a single second trying?

In other words: I am looking for answers that can confirm "yes, it worked for our large code base"; or "no, it is not at all that easy".

Upvotes: 6

Views: 5268

Answers (3)

GhostCat
GhostCat

Reputation: 140467

My current assessment regarding regarding our projects is to stay with JUnit 4.12 for the moment.

As of now, we our build setup is "different" for eclipse and our "backend build"; meaning: we can't use maven/gradle to build within eclipse. And I simply failed to just identify/download the JARs I would need to replace the junit-4.12.jar within our eclipse setup; not even thinking about also providing some (but which) other JARs in order to have JUnit 5 available.

Upvotes: 0

acm
acm

Reputation: 2120

As stated by the JUnit 5 User Guide:

Just make sure that the junit-vintage-engine artifact is in your test runtime path. In that case JUnit 3 and JUnit 4 tests will automatically be picked up by the JUnit Platform launcher.

See the example projects in the junit5-samples repository to find out how this is done with Gradle and Maven.

Upvotes: 10

namingFailed
namingFailed

Reputation: 289

http://junit.org/junit5/docs/current/user-guide/

junit-vintage-engine is for running junit4 or 3 so it looks like it 'JUnit Vintage test engine implementation that allows to run vintage JUnit tests, i.e. tests written in the JUnit 3 or JUnit 4 style, on the new JUnit Platform.'

Upvotes: 2

Related Questions