junit-interface icon indicating copy to clipboard operation
junit-interface copied to clipboard

Compatibility with Spring 4.3 and above

Open petermant opened this issue 7 years ago • 2 comments

I have a project with a dependency on Spring Batch Test 4.1.0-RELEASE, which brings in Spring Test 5.1.2-RELEASE with it.

If I include junit-interface on the classpath, and plain dependencies (no exclusions) then ./sbt test gives:

[debug] Test run started [debug] Test run finished: 0 failed, 0 ignored, 0 total, 0.001s

I have tried updated the dependencies to exclude JUnit 4.12, as follows:

libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test" libraryDependencies += "org.springframework.batch" % "spring-batch-test" % "4.1.0.RELEASE" % "test" exclude("junit", "junit")

This gives the following from ./sbt test:

[debug] Running TaskDef(LoadInternalUsersTests, com.novocode.junit.RunWithFingerprint@310e1f40, false, [SuiteSelector]) ...snip... [error] Test LoadInternalUsersTests.initializationError failed: java.lang.ExceptionInInitializerError: null, took 0.004 sec [error] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [error] ... [error] Caused by: java.lang.IllegalStateException: SpringJUnit4ClassRunner requires JUnit 4.12 or higher. [error] at org.springframework.util.Assert.state(Assert.java:73) [error] at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.(SpringJUnit4ClassRunner.java:104)

In SpringJUnit4ClassRunner.java there is a note saying "As of Spring Framework 4.3, this class requires JUnit 4.12 or higher".

Is there a reason why junit-interface won't run the tests when JUnit 4.12 is on the classpath and 4.11 is evicted?

petermant avatar Nov 14 '18 13:11 petermant

Not sure what's happening here, but the latest code uses JUnit 4.12, so hopefully a new release would fix this for you. Perhaps you can find someone on the SBT mailing list or gitter.im chat room to cut a release

benmccann avatar Nov 14 '18 22:11 benmccann

Thanks, interesting idea. I tried with checking out the latest code, building, and publishing into my local ivy repository. Unfortunately it made no difference so there's something else going on maybe. At least (I think) I've ruled out it being an issue with JUnit 4.12. Will look in more depth next week.

petermant avatar Nov 16 '18 13:11 petermant