Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sbt: Add dependency on scalatest library. Where?

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:

  • 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'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?

like image 984
Heinzi Avatar asked Sep 26 '12 12:09

Heinzi


1 Answers

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

like image 67
semberal Avatar answered Sep 21 '22 09:09

semberal