找不到GeneratorDrivenPropertyChecks特质

问题描述 投票:0回答:1

我定义了这些测试依赖关系

/ Test Dependencies
lazy val wiremock             = "com.github.tomakehurst"      % "wiremock-jre8"             % "2.25.1"
lazy val playTest             = "com.typesafe.play"          %% "play-test"                 % "2.8.1"
lazy val scalaTestPlusPlay    = "org.scalatestplus.play"     %% "scalatestplus-play"        % "5.1.0"
lazy val mockito              = "org.mockito"                %% "mockito-scala"             % "1.10.2"
lazy val scalamock            = "org.scalamock"              %% "scalamock"                 % "4.4.0"
lazy val scalacheck_shapeless = "com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % "1.2.3"
lazy val scalatest            = "org.scalatest"              %% "scalatest"                 % "3.1.1"

但是我找不到这个特性来混入我的测试规范类中。GeneratorDrivenPropertyChecks. 我不知道在依赖性方面我缺少什么。在 org.scalatest.prop 我没有看到这个特性。我只看到TableDrivenPropertyChecks。

scala scalatest
1个回答
2
投票

GeneratorDrivenPropertyChecks 似乎已经被 移除 在ScalaTest 3.1.0中

我们将其私有化,这样就不会再耽误3.1.0的发布。我想研究一种更好的方式来整合收缩,就像Hedgehog等工具所做的那样。3.2.0版本我们希望和3.1.0完全一样,除了模块化。 之后我们计划完成并发布ScalaTest的Generator。 同时我们认为大家会继续使用ScalaCheckDrivenPropertyChecks和Gen,它可以在这里获得。

https:/github.comscalatestscalatestplus-scalacheck。

相反,可以尝试使用 ScalaCheckDrivenPropertyChecks 如是

import org.scalacheck.Gen
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks

class HelloSpec extends AnyFlatSpec with Matchers with ScalaCheckDrivenPropertyChecks {
  "ScalaCheckDrivenPropertyChecks" should "provide forAll" in {
    forAll(Gen.choose(1, 100)) { i =>
      i shouldBe i
    }
  }
}

哪儿

libraryDependencies ++= Seq(
  "org.scalatestplus" %% "scalacheck-1-14" % "3.1.1.1" % Test,
  "org.scalatest" %% "scalatest" % "3.1.1" % Test
)
© www.soinside.com 2019 - 2024. All rights reserved.