WordSpec,使用'in'和pending似乎不起作用

时间:2012-08-25 10:38:28

标签: scala scalatest

从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对我来说似乎更自然

1 个答案:

答案 0 :(得分:9)

这是一个编译器错误。我假设你已导入:

import org.scalatest.fixture.WordSpec

但您需要导入:

import org.scalatest.WordSpec