2016-12-04 112 views
0

使用SBT測試代碼SBT項目找不到ScalaCheck

package examples 
import org.specs2._ 

class ScalaCheckExamplesSpec extends Specification with ScalaCheck { def is = s2""" 
    startsWith ${ prop { (a: String, b: String) => (a+b) must startWith(a) } } 
    endsWith ${ prop { (a: String, b: String) => (a+b) must endWith(b) } } 
    substring ${ prop { (a: String, b: String) => (a+b).substring(a.length) === b } } 
    substring ${ prop { (a: String, b: String, c: String) => (a+b+c).substring(a.length, a.length+b.length) === b } }                              """ 
} 

與SBT配置:

libraryDependencies ++= Seq(
    "org.specs2" %% "specs2-core" % "3.8.5" % "test", 
    "org.scalacheck" %% "scalacheck" % "1.13.4" % "test" 
) 

ScalaCheck無法找到:

ScalaCheckExamplesSpec.scala:11: not found: type ScalaCheck 
[error] class ScalaCheckExamplesSpec extends Specification with ScalaCheck { 

我該如何解決錯誤?

+0

是否使用Scala的2.12? – Pavel

+0

使用版本2.11.6,但未在build.sbt – Johan

回答

3

您需要:

libraryDependencies ++= Seq(
    "org.specs2" %% "specs2-core" % "3.8.5" % "test", 
    // the scalacheck lib will come as a transitive 
    // dependency 
    "org.specs2" %% "specs2-scalacheck" % "3.8.5" % "test" 
) 
+0

中使用'build.sbt中的'scalaVersion:=「2.12.0」'指定,需要使用版本'3.8.6'而不是版本'3.8。 5' – Johan