我正在使用sbt.version = 1.1.5。 我想用powermock来模拟静态方法。
我的build.sbt
...
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
...
"org.mockito" % "mockito-core" % "2.18.3" % "test",
"org.powermock" % "powermock-api-mockito" % "1.7.4" % "test",
"org.powermock" % "powermock-module-javaagent" % "1.7.4" % "test",
"org.powermock" % "powermock-module-junit4-rule-agent" % "1.7.4" % "test"
)
MyClassSpec.scala
...
import org.powermock.modules.junit4.PowerMockRunner
...
@RunWith(classOf[PowerMockRunner])
...
使用sbt test获得了以下错误。
[error] /foo/MyClassSpec.scala:15:8: object PowerMockRunner is not a member of package org.powermock.modules.junit4
[error] import org.powermock.modules.junit4.PowerMockRunner
[error] ^
[error] /foo/MyClassSpec.scala:18:18: not found: type PowerMockRunner
[error] @RunWith(classOf[PowerMockRunner])
[error] ^
[error] two errors found
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 6 s, completed 2018/05/24 2:10:44