gpt4 book ai didi

scala - java.lang.IncompatibleClassChangeError:使用ScalaCheck和ScalaTest实现类

转载 作者:行者123 更新时间:2023-12-03 11:34:03 26 4
gpt4 key购买 nike

尝试使用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.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.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.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.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).

关于scala - java.lang.IncompatibleClassChangeError:使用ScalaCheck和ScalaTest实现类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35312410/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com