I created a scala project using SBT and wrote some unit test cases using scalatest. But somehow sbt test
can't find the org.scalatest package.
Here my project definition files:
src/main/scala respective src/test/scala
build.sbt
:
name := "MyProject" version := "0.1" scalaVersion := "2.9.2"
project/plugins.sbt
:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
project/build.sbt
:
libraryDependencies += "org.scalatest" %% "scalatest" % "1.8" % "test"
I'm using SBT 0.11.3.
Compiling the program using sbt compile
on the console works fine. Furthermore I found the scalatest jar in ~/.ivy2
, so SBT must have downloaded it.
But when running sbt test
, it says
object scalatest is not a member of package org
[error] import org.scalatest.FlatSpec
...[many errors alike]
And running sbt eclipse
creates a .classpath that doesn't contain the scalatest jar.
Do I have to specify the test dependencies somewhere else? How should I add the scalatest library?
将libraryDependencies += "org.scalatest" %% "scalatest" % "1.8" % "test"
放入build.sbt ,而不是project / build.sbt 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.