EDIT : it works if the file is in src/test/scala/tests/ but not in src/main/scala/mypackage/ Why ?
I have try solutions from topics with people having nearly the same issue but none works.
In details, I have this in build.sbt :
libraryDependencies ++= Seq( ... "org.scalatest" % "scalatest_2.10" % "2.2.1" % "test", ...
In intellij a class with:
import org.scalatest.{BeforeAndAfterAll, Suite}
with {BeforeAndAfterAll, Suite} in red so i guess scalatest is found
sbt package does not work too :
object scalatest is not a member of package org [error] import org.scalatest. {BeforeAndAfterAll, Suite}
I have already tries this :
Nothing works
Any idea ?
You should take a look at sbt project structure:
src/ main/ resources/ <files to include in main jar here> scala/ <main Scala sources> java/ <main Java sources> test/ resources <files to include in test jar here> scala/ <test Scala sources> java/ <test Java sources>
Your scala tests should go under src/test/scala/
.
If you really want to use scalatest in main (and you know what you are trying to do), try this:
"org.scalatest" % "scalatest_2.10" % "2.2.1",
In your original build.sbt
, "test" is the configuration and it means that scalatest will only be on the test classpath and it isn’t needed by the main sources. This is generally good practice for libraries because your users don’t typically need your test dependencies to use your library (ref).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With