I am trying to learn the basics of Scala, scalatest, and sbt and I'm following a tutorial. This is my built.sbt
file:
name := "demo-hello"
version := "0.1"
scalaVersion := "2.12.6"
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.1.0" % "test"
I have a test that looks like this (showing this is probably unnecessary:
package demo
import org.scalatest.FunSuite
class HelloTest extends FunSuite {
test("say hello method works correctly") {
val hello = new Hello
assert(hello.sayHello("Scala") == "Hello, Scala!")
}
}
What should I do from here? I am trying to run the test but I get this error:
Error:(8, 36) can't expand macros compiled by previous versions of Scala
assert(hello.sayHello("Scala") == "Hello, Scala!")
I'm not that familiar with the %
symbol btw.
FIX
I changed my build.sbt
to this:
name := "demo-hello"
version := "0.1"
scalaVersion := "2.10"
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.1.0" % "test"
Remaining questions:
- So it seems downgrading to scalaVersion "2.10" worked. Why?
- What is an artifact?
scalatest
is apparently an artifact? - Where is scalaversion 2.10 kept on my machine? It seems I only have scala 2.12. Where in my project folder is version 2.10?
"org.scalatest" % "scalatest_2." % "2.1.0" % "test"
looks weird. Could you try to change it as"org.scalatest" %% "scalatest" % "2.1.0" % "test"
? – tkachuko