Scala 无法使用GeneratorDrivenPropertyChecks启动测试
我想使用scalacheck和scalatest来测试一些具有随机输入值的对象。 首先,我尝试了一个简单的示例,但如果我通过Eclipse或sbt启动它,它会抛出一个错误。 代码是:Scala 无法使用GeneratorDrivenPropertyChecks启动测试,scala,scalatest,scalacheck,Scala,Scalatest,Scalacheck,我想使用scalacheck和scalatest来测试一些具有随机输入值的对象。 首先,我尝试了一个简单的示例,但如果我通过Eclipse或sbt启动它,它会抛出一个错误。 代码是: package test import org.scalatest._ import org.scalatest.prop.GeneratorDrivenPropertyChecks class SamplePropGenCheck extends PropSpec with Ge
package test
import org.scalatest._
import org.scalatest.prop.GeneratorDrivenPropertyChecks
class SamplePropGenCheck extends PropSpec with GeneratorDrivenPropertyChecks with Matchers {
property("Int simple test") {
forAll("a") { a : Int =>
whenever (a > 0) {
(a * 2) should be (a + a)
}
}
}
}
在执行时,我有以下错误:
*** RUN ABORTED ***
java.lang.AbstractMethodError:
org.scalatest.prop.Configuration$$anon$1.TestParams()Lorg/scalacheck/Test$Parameters$TestParams$;
at org.scalacheck.Test$Parameters$class.$init$(Test.scala:98)
at org.scalatest.prop.Configuration$$anon$1.<init>(Configuration.scala:332)
at org.scalatest.prop.Configuration$class.getParams(Configuration.scala:332)
***运行中止***
java.lang.AbstractMethodError:
org.scalatest.prop.Configuration$$anon$1.TestParams()Lorg/scalacheck/Test$Parameters$TestParams$;
位于org.scalacheck.Test$Parameters$class.$init$(Test.scala:98)
位于org.scalatest.prop.Configuration$$anon$1。(Configuration.scala:332)
位于org.scalatest.prop.Configuration$class.getParams(Configuration.scala:332)
我将scalatest_2.11-2.2.1和scalacheck_2.11-1.12.3与scala 2.11.6一起使用
当我做另一个测试时,使用TableDrivenPropertyChecks而不是GeneratorDrivenPropertyChecks,它工作得很好
我在文档或谷歌中找不到任何帮助。这是一个代码错误、bug还是版本问题?
有人能帮我找到解决方案吗?尝试降级到scalacheck 1.12.2 我在scalacheck_2.10-1.12.3中看到了同样的错误。它在scalacheck_2.10-1.12.2中工作
编辑:ScalaCheck 1.12.3存在ScalaTest兼容性问题,该问题已在1.12.4-SNAPSHOT中修复 尝试降级到scalacheck 1.12.2 我在scalacheck_2.10-1.12.3中看到了同样的错误。它在scalacheck_2.10-1.12.2中工作
编辑:ScalaCheck 1.12.3存在ScalaTest兼容性问题,该问题已在1.12.4-SNAPSHOT中修复 谢谢你关于这个问题的链接,我还没有找到。1.12.2版本解决了这个问题。谢谢你关于这个问题的链接,我还没有找到它。1.12.2版本解决了这个问题。