1

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

4

1 回答 1

9

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

import org.scalatest.fixture.WordSpec

但您需要导入:

import org.scalatest.WordSpec
于 2012-08-25T10:56:01.680 回答