How to run JUnit 4.11 test cases with SBT?

I have the following in build.sbt :

libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test" libraryDependencies += "junit" % "junit" % "4.11" % "test" 

I noticed that junit-interface 0.10 is dependent on junit-dep 4.10 . This makes it impossible to compile tests that use assertNotEquals , which was introduced in junit 4.11 .

How to run JUnit 4.11 with SBT?

+7
junit sbt
source share
2 answers

Use junit-interface 0.11 to avoid dependency on junit-dep:

 libraryDependencies += "junit" % "junit" % "4.12" % "test" libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test" 

UPDATE: junit-interface 0.11 makes this reliable, depending on junit, not junit-dep.

+4
source share

I would do this:

 libraryDependencies ++= Seq( "junit" % "junit" % "4.11" % Test, "com.novocode" % "junit-interface" % "0.11" % Test exclude("junit", "junit-dep") ) 

Excluding what we do not want, it does not interfere. It does not depend on the order.

+8
source share

All Articles