为什么在 specs2 中使用单一规范的 ScalaTest 测试报告“[info] 未执行任何测试”?
Why does test report "[info] No tests were executed" for ScalaTest with a single specification in specs2?
我在 specs2 中写了一些非常基本的测试。
import org.scalatest._
import org.specs2.mutable._
class MySpec extends Specification {
"Arithmetic" should {
"add" in {
"two numbers " in {
1 + 1 mustEqual (2)
}
"three numbers" in {
1 + 1 + 1 mustEqual (3)
}
"compare numbers" in {
2 must be lessThanOrEqualTo(1)
}
}
}
}
当我 运行 时,他们似乎 运行 如预期的那样
可以看到有2个测试成功,1个测试失败。不错。
但我不明白为什么 Specs2 会用黄色显示 "No tests were executed"。
怎么回事?
两项测试 运行,一项 MySpec
,另一项 ScalaTest
。 ScalaTest
是 No tests were executed
。
那里的输出分为三个部分:1. MySpec
的结果,2. ScalaTest
的结果,以及 3. 所有结果(摘要)。
tl;dr 在构建中删除 libraryDependencies
中的一个测试依赖项并修复 MySpec
.
中的导入
该消息的原因是项目中的 libraryDependencies
同时使用了 specs2 和 ScalaTest 库,可能如下所示:
libraryDependencies += "org.specs2" %% "specs2-core" % "3.6.2" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.5" % "test"
否则,MySpec
规范在导入 org.scalatest._
和 import org.specs2.mutable._
时会出现编译错误:
import org.scalatest._
import org.specs2.mutable._
我在 specs2 中写了一些非常基本的测试。
import org.scalatest._
import org.specs2.mutable._
class MySpec extends Specification {
"Arithmetic" should {
"add" in {
"two numbers " in {
1 + 1 mustEqual (2)
}
"three numbers" in {
1 + 1 + 1 mustEqual (3)
}
"compare numbers" in {
2 must be lessThanOrEqualTo(1)
}
}
}
}
当我 运行 时,他们似乎 运行 如预期的那样
可以看到有2个测试成功,1个测试失败。不错。
但我不明白为什么 Specs2 会用黄色显示 "No tests were executed"。 怎么回事?
两项测试 运行,一项 MySpec
,另一项 ScalaTest
。 ScalaTest
是 No tests were executed
。
那里的输出分为三个部分:1. MySpec
的结果,2. ScalaTest
的结果,以及 3. 所有结果(摘要)。
tl;dr 在构建中删除 libraryDependencies
中的一个测试依赖项并修复 MySpec
.
该消息的原因是项目中的 libraryDependencies
同时使用了 specs2 和 ScalaTest 库,可能如下所示:
libraryDependencies += "org.specs2" %% "specs2-core" % "3.6.2" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.5" % "test"
否则,MySpec
规范在导入 org.scalatest._
和 import org.specs2.mutable._
时会出现编译错误:
import org.scalatest._
import org.specs2.mutable._