情况:我想为我的 Play 执行 JUnit 测试用例!Jenkins 服务器上的 2.0 应用程序。要在我想使用 SBT 的服务器上构建和测试我的应用程序(使用命令序列:)clean compile test
。
问题:不管 Jenkins,该命令play test
使用的类路径与该命令不同java -jar "sbt-launch.jar" test
(这两个命令都在我的 play 项目的根目录中执行,两个命令都使用相同的 sbt 版本 0.12.2)。我的测试用例可以编译,play test
但java -jar "sbt-launch.jar" test
编译器抱怨org.junit.rules.TestWatcher
缺少一些 JUnit 类(例如,)。
分析:该命令show test:full-classpath
显示类路径确实不同:
play test
类路径包含:Attributed(<playhome>\repository\local\junit\junit-dep\4.10\jars\junit-dep.jar)
java -jar "sbt-launch.jar test
类路径包含:Attributed(<userhome>\.ivy2\cache\junit\junit-dep\jars\junit-dep-4.8.2.jar)
问题:任何想法如何确保java -jar "sbt-launch.jar test
使用相同的类路径play test
?
构建.scala:
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "my app"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Play framework dependencies
javaCore, javaJdbc, javaEbean,
// Add your project dependencies here
"com.typesafe" %% "play-plugins-mailer" % "2.1.0",
"com.feth" %% "play-authenticate" % "0.2.5-SNAPSHOT",
"org.mongodb" % "mongo-java-driver" % "2.10.1",
"com.embedly" % "embedly-api" % "0.1.5",
"org.mockito" % "mockito-all" % "1.9.5",
"org.mongojack" % "mongojack" % "2.0.0-RC5",
"commons-io" % "commons-io" % "2.3"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
resolvers += Resolver.url("play-easymail (release)", url("http://joscha.github.com/play-easymail/repo/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-easymail (snapshot)", url("http://joscha.github.com/play-easymail/repo/snapshots/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-authenticate (release)", url("http://joscha.github.com/play-authenticate/repo/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-authenticate (snapshot)", url("http://joscha.github.com/play-authenticate/repo/snapshots/"))(Resolver.ivyStylePatterns)
)
}