无法使用GeneratorDrivenPropertyChecks启动测试

vol*_*a17 1 scala scalatest scalacheck

我想使用scalalatest scalacheck来测试一些具有随机输入值的对象.首先,我尝试了一个简单的示例,但如果我通过Eclipse或sbt启动它,则会抛出错误.代码是:

    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 Code Online (Sandbox Code Playgroud)

在执行时,我有这个错误:

    *** 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)
Run Code Online (Sandbox Code Playgroud)

我使用scalatest_2.11-2.2.1和scalacheck_2.11-1.12.3与scala 2.11.6

当我使用TableDrivenPropertyChecks而不是GeneratorDrivenPropertyChecks进行其他测试时,它运行良好.

我在docs或google中找不到任何帮助.是代码错误,错误还是版本问题?有人可以帮我找到解决方案吗?

bio*_*urk 5

尝试降级到scalacheck 1.12.2.

我在scalacheck_2.10-1.12.3看到同样的错误.它适用于scalacheck_2.10-1.12.2.

编辑:ScalaCheck 1.12.3在1.12.4-SNAPSHOT中修复了ScalaTest兼容性问题. https://github.com/rickynils/scalacheck/issues/165