java.lang.IncompatibleClassChangeError: Implementing class with ScalaCheck and ScalaTest
java.lang.IncompatibleClassChangeError: Implementing class with ScalaCheck and ScalaTest
我在尝试使用 ScalaCheck 和 ScalaTest 编写测试时遇到了一个讨厌的异常。这是我的依赖项:
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.6" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.0" % "test"
)
这是我的测试:
import org.scalatest.PropSpec
import org.scalatest.prop.Checkers
class MyPropSpec extends PropSpec with Checkers {
property("List.concat") {
check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size)
}
}
当我尝试 运行 时,我得到:
DeferredAbortedSuite:
Exception encountered when attempting to run a suite with class name: org.scalatest.DeferredAbortedSuite *** ABORTED ***
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
...
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
...
我在这里错过了什么?
ScalaTest 2.2.6 与 ScalaCheck 1.13.0 不兼容。降级到 "scalacheck" % "1.12.5" 有帮助。
这被报告为 https://github.com/rickynils/scalacheck/issues/217。该问题已通过以下解决方案关闭:
All current releases of ScalaTest (2.2.6, 3.0.0 etc) are built against ScalaCheck 1.12.1 (see https://github.com/scalatest/scalatest/blob/master/project/scalatest.scala#L134). Therefore, there are no guarantees that you can simply swap out ScalaCheck 1.12.x for 1.13.y. ScalaCheck only maintains binary compatibility within the same minor version series (1.12.1, 1.12.2, 1.12.3 etc).
我在尝试使用 ScalaCheck 和 ScalaTest 编写测试时遇到了一个讨厌的异常。这是我的依赖项:
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "2.2.6" % "test",
"org.scalacheck" %% "scalacheck" % "1.13.0" % "test"
)
这是我的测试:
import org.scalatest.PropSpec
import org.scalatest.prop.Checkers
class MyPropSpec extends PropSpec with Checkers {
property("List.concat") {
check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size)
}
}
当我尝试 运行 时,我得到:
DeferredAbortedSuite:
Exception encountered when attempting to run a suite with class name: org.scalatest.DeferredAbortedSuite *** ABORTED ***
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
...
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:368)
at java.net.URLClassLoader.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
...
我在这里错过了什么?
ScalaTest 2.2.6 与 ScalaCheck 1.13.0 不兼容。降级到 "scalacheck" % "1.12.5" 有帮助。
这被报告为 https://github.com/rickynils/scalacheck/issues/217。该问题已通过以下解决方案关闭:
All current releases of ScalaTest (2.2.6, 3.0.0 etc) are built against ScalaCheck 1.12.1 (see https://github.com/scalatest/scalatest/blob/master/project/scalatest.scala#L134). Therefore, there are no guarantees that you can simply swap out ScalaCheck 1.12.x for 1.13.y. ScalaCheck only maintains binary compatibility within the same minor version series (1.12.1, 1.12.2, 1.12.3 etc).