SBT: Add the dependence on the ScaLatest library. Where is?

I created a scala project using SBT and wrote some unit test cases using scalatest. But somehow, sbt test cannot find the org.scalatest package.

This is my project definition file:

>The source is the respective src/test/scala of src/main/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 am using SBT 0.11.3.

Using sbt compile on the console to compile the program works fine.
In addition, I found the scalatest jar in ~/.ivy2, so SBT must download it.

But when running the 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 will create a .classpath that does not contain the scalatest jar.

Do I have to specify test dependencies elsewhere? item? How can I add the scalatest library?

Put libraryDependencies = “org.scalatest”%%”scalatest”%”1.8″%”test “Put into build.sbt instead of project/build.sbt.

I created a scala project using SBT and wrote some unit test cases using scalatest. But somehow, sbt test cannot find the org.scalatest package.

This is my project definition file:

>The source is src/main/scala’s 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 am using SBT 0.11.3.

Using sbt compile on the console to compile the program is working fine.
In addition, I am in ~/.ivy2 The scalatest jar is found in, so SBT must download it.

However, when running the 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 will create a file that does not contain scalatest j ar’s.classpath.

Do I have to specify test dependencies elsewhere? How can I add the scalatest library?

Put libraryDependencies=”org.scalatest”%%”scalatest”%”1.8″%”test” into build.sbt instead of project/build .sbt.

Leave a Comment

Your email address will not be published.