从Specs2迁移到Scalatest我尝试使用WordSpec,但没有运气。我已经使用了来自Testing Actor Systems的示例,但由于错误,它对我无效。然后我从scaladoc复制了基本测试,仍然有同样的问题。你能指导我,我在这里做错了吗?
class MasterSpec extends WordSpec {
"A Set" when {
"empty" should {
"have size 0" in (pending)
"produce NoSuchElementException when head is invoked" in {
intercept[NoSuchElementException] {
Set.empty.head
}
}
}
}
}
这会出现以下错误消息:
[error] /Users/bam/Projects/ppm/core/src/test/scala/net/batyuk/ppm/core/MasterSpec.scala:12: overloaded method value in with alternatives:
[error] (testFun: () => Any)Unit <and>
[error] (testFun: MasterSpec.this.FixtureParam => Any)Unit
[error] cannot be applied to (org.scalatest.PendingNothing)
[error] "have size 0" in (pending)
[error] ^
[error] one error found
试图转移到FunSpec,但不能强迫自己进入它,WordSpec对我来说似乎更自然
答案 0 :(得分:9)
这是一个编译器错误。我假设你已导入:
import org.scalatest.fixture.WordSpec
但您需要导入:
import org.scalatest.WordSpec