Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run JUnit 4.11 test cases with SBT?

Tags:

junit

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 depends on junit-dep 4.10. This makes it impossible to compile tests that use assertNotEquals which was introduced in junit 4.11.

How do I run JUnit 4.11 test cases with SBT?

like image 589
Alain O'Dea Avatar asked Mar 05 '14 14:03

Alain O'Dea


2 Answers

I would do this:

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

By excluding what we don't desire, it doesn't interfere. This doesn't depend on ordering.

like image 119
david.perez Avatar answered Oct 24 '22 12:10

david.perez


Use junit-interface 0.11 to avoid the 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 by depending on junit rather than junit-dep.

like image 24
Alain O'Dea Avatar answered Oct 24 '22 11:10

Alain O'Dea