scalac: Error: requirement failed: package stubbing
scalac: Error: requirement failed: package stubbing
我正在使用 Scala 2.12。这是我的 build.sbt 文件
libraryDependencies ++= Seq(
"net.codingwell" %% "scala-guice" % "4.1.0",
"org.scalatest" %% "scalatest" % "3.0.3" % "test",
"org.scalamock" %% "scalamock-scalatest-support" % "3.5.0" % "test"
)
我正在尝试为 Guice 编写一个测试模块,它也使用 Mocking
我试过了
class TestModule extends ScalaModule with MockitoSugar{
val x = mock[TestPartialMock]
override def configure(): Unit = {
bind[Test1]
bind[Test2]
}
}
我收到错误消息
Error:scalac: Error: requirement failed: package stubbing
java.lang.IllegalArgumentException: requirement failed: package stubbing
at scala.reflect.internal.Types$ModuleTypeRef.<init>(Types.scala:1879)
at scala.reflect.internal.Types$PackageTypeRef.<init>(Types.scala:1897)
at scala.reflect.internal.Types$TypeRef$.apply(Types.scala:2401)
at scala.reflect.internal.Types.typeRef(Types.scala:3553)
at scala.reflect.internal.Types.typeRef$(Types.scala:3536)
at scala.reflect.internal.SymbolTable.typeRef(SymbolTable.scala:16)
at s
我也试过了
class TestModule extends AbstractModule with ScalaModule with MockitoSugar {
override def configure() = {
}
}
但现在我得到错误
Error:(14, 17) Symbol 'type <none>.stubbing.Answer' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.defaultAnswer'.
Make sure that type Answer is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.stubbing.
override def configure() = {
然后我试了
class TestModule extends AbstractModule with ScalaModule with MockFactory with MockitoSugar {
override def configure() = {
}
}
但是我得到这个错误
Error:(14, 17) Symbol 'type <none>.mockito.MockSettings' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.mockSettings'.
Make sure that type MockSettings is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.mockito.
override def configure() = {
在我看来,不可能在同一个 class.
中使用 Guice AbstractFactory 和 MockitoSugar
我多试了一点,我解决了。在这里留下答案,以便其他人可以找到。
这个有效
SBT
"net.codingwell" %% "scala-guice" % "4.1.0",
"org.scalatest" % "scalatest_2.12" % "3.0.3",
"org.mockito" % "mockito-core" % "2.7.22"
现在将 class 定义为
class TestModule extends AbstractModule with ScalaModule with MockitoSugar {
override def configure() = {}
}
我正在使用 Scala 2.12。这是我的 build.sbt 文件
libraryDependencies ++= Seq(
"net.codingwell" %% "scala-guice" % "4.1.0",
"org.scalatest" %% "scalatest" % "3.0.3" % "test",
"org.scalamock" %% "scalamock-scalatest-support" % "3.5.0" % "test"
)
我正在尝试为 Guice 编写一个测试模块,它也使用 Mocking
我试过了
class TestModule extends ScalaModule with MockitoSugar{
val x = mock[TestPartialMock]
override def configure(): Unit = {
bind[Test1]
bind[Test2]
}
}
我收到错误消息
Error:scalac: Error: requirement failed: package stubbing
java.lang.IllegalArgumentException: requirement failed: package stubbing
at scala.reflect.internal.Types$ModuleTypeRef.<init>(Types.scala:1879)
at scala.reflect.internal.Types$PackageTypeRef.<init>(Types.scala:1897)
at scala.reflect.internal.Types$TypeRef$.apply(Types.scala:2401)
at scala.reflect.internal.Types.typeRef(Types.scala:3553)
at scala.reflect.internal.Types.typeRef$(Types.scala:3536)
at scala.reflect.internal.SymbolTable.typeRef(SymbolTable.scala:16)
at s
我也试过了
class TestModule extends AbstractModule with ScalaModule with MockitoSugar {
override def configure() = {
}
}
但现在我得到错误
Error:(14, 17) Symbol 'type <none>.stubbing.Answer' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.defaultAnswer'.
Make sure that type Answer is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.stubbing.
override def configure() = {
然后我试了
class TestModule extends AbstractModule with ScalaModule with MockFactory with MockitoSugar {
override def configure() = {
}
}
但是我得到这个错误
Error:(14, 17) Symbol 'type <none>.mockito.MockSettings' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.mockSettings'.
Make sure that type MockSettings is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.mockito.
override def configure() = {
在我看来,不可能在同一个 class.
中使用 Guice AbstractFactory 和 MockitoSugar我多试了一点,我解决了。在这里留下答案,以便其他人可以找到。
这个有效
SBT
"net.codingwell" %% "scala-guice" % "4.1.0",
"org.scalatest" % "scalatest_2.12" % "3.0.3",
"org.mockito" % "mockito-core" % "2.7.22"
现在将 class 定义为
class TestModule extends AbstractModule with ScalaModule with MockitoSugar {
override def configure() = {}
}