nietsnegttiw
nietsnegttiw

Reputation: 371

Cannot Resolve Symbol "Scalatest"

I am trying to use scalatest, but Intellij cannot recognize:

import org.scalatest._

Here is my build.sbt file, located in the same directory as my scalatest.jar file.

scalaVersion := "2.11.2"

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"

Thanks

Upvotes: 10

Views: 12701

Answers (1)

0__
0__

Reputation: 67280

So you have by convention two source folders:

src/main/scala/...
src/test/scala/...

The first is shown blue, the second green in IntelliJ IDEA. The library dependencies in sbt are associated with either of these, so

"org.foo" % "bar_2.11" % "1.2.3"

Is a main dependency, available to main sources (and also test, because test depends on main). And

"org.foo" % "bar_2.11" % "1.2.3" % "test"

Is a test dependency, only available to test sources. The idea is that these are libraries which are not required for your product, but only to run the unit tests.


In your example, Scala-Test is only available to test sources, so trying to import it from main sources will fail.

Upvotes: 17

Related Questions