sky*_*erl 2 scala maven scalatest
因此,我们有一个Scala程序(使用Maven构建),我们想使用Scalatest进行测试。我们正在运行Scala 2.11.8和Scalatest 3.0.1(我们尝试了3.0.3无济于事)
当我们的测试使用assert()宏运行任何内容时,我们将收到以下错误:
error: can't expand macros compiled by previous versions of Scala
assert(true)
^
Run Code Online (Sandbox Code Playgroud)
它指向,true但是问题在于我们放入的任何内容assert()。我们的POM对Scalatest具有以下依赖性:
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我们试图执行的代码是:
import org.scalatest.{FlatSpec, _}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class Testing extends FlatSpec {
//test
var number = 0;
"An empty Set" should "have size 0" in {
assert(true)
}
}
Run Code Online (Sandbox Code Playgroud)
很多人说这是使用Scala 2.11的问题,但包括2.10依赖项,但我们使用的是2.11。任何帮助将非常感激。我还应该注意,我们使用Scala 2.10进行了尝试,并且可以正常工作。