从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
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这给出以下错误消息:
[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
Run Code Online (Sandbox Code Playgroud)
试图转移到FunSpec,但不能强迫自己进入它,WordSpec对我来说似乎更自然
这是编译器错误.我假设你已导入:
import org.scalatest.fixture.WordSpec
Run Code Online (Sandbox Code Playgroud)
但你需要导入:
import org.scalatest.WordSpec
Run Code Online (Sandbox Code Playgroud)