sbt项目找不到ScalaCheck

时间:2016-12-04 17:53:22

标签: scala sbt specs2

使用sbt测试代码

function contatore(number){

/* if 0, we have to stop the counter and return to the caller */
if(number == 0){
    return;
}else{

    /* js recursive: wait 1 second, than re-call this function with number-1 as parameter*/
    setTimeout(function(){contatore(number - 1)}, 1000);

    /* you can finally inner the html */
    document.getElementById("main").innerHTML = number;
}
}

使用sbt配置:

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 } }                                                                                                                       """
}

无法找到班级libraryDependencies ++= Seq( "org.specs2" %% "specs2-core" % "3.8.5" % "test", "org.scalacheck" %% "scalacheck" % "1.13.4" % "test" )

ScalaCheck

如何解决错误?

1 个答案:

答案 0 :(得分: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"
)