WordSpec,使用"in"和挂起似乎不起作用



从Specs2转移到Scalatest,我尝试使用WordSpec,但没有成功。我使用了TestingActorSystems的样本,但它对我来说不起作用。然后,我从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对我来说似乎更自然了

这是一个编译器错误。我想你已经导入了:

import org.scalatest.fixture.WordSpec

但你需要导入:

import org.scalatest.WordSpec

最新更新