Sbt: Add a dependency on the scalatest library. Where?

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

Here are my project definition files:

  • Sources are in 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 am using SBT 0.11.3.

Compiling a program using sbt compilethe console works fine. Also, I found the scalar jar in ~/.ivy2, so SBT should load it.

But at startup, sbt testhe says

object scalatest is not a member of package org
[error] import org.scalatest.FlatSpec
...[many errors alike]

And the launch sbt eclipsecreates a .classpath that does not contain a scalar jar.

Should I specify test dependencies elsewhere? How to add scalatest library?

+5
source share
1 answer

libraryDependencies += "org.scalatest" %% "scalatest" % "1.8" % "test" build.sbt, project/build.sbt.

+10

All Articles