如何使用SBT运行JUnit 4.11测试用例?

Ala*_*Dea 9 junit sbt

我在build.sbt中有以下内容:

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

libraryDependencies += "junit" % "junit" % "4.11" % "test"
Run Code Online (Sandbox Code Playgroud)

我注意到junit-interface 0.10依赖于junit-dep 4.10.这使得无法编译使用junit 4.11中引入的assertNotEquals的测试.

如何使用SBT运行JUnit 4.11测试用例?

dav*_*rez 11

我会这样做:

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

通过排除我们不想要的东西,它不会干扰.这不取决于订购.


Ala*_*Dea 7

使用junit-interface 0.11来避免对junit-dep的依赖:

libraryDependencies += "junit" % "junit" % "4.12" % "test"

libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
Run Code Online (Sandbox Code Playgroud)

更新:junit-interface 0.11依赖于junit而不是junit-dep使其可靠.