带有Play的specs2:比“1 mustEqual 1”更好的占位符?

时间:2016-11-16 19:32:31

标签: scala unit-testing playframework specs2

在为Play框架编写specs2测试时,尝试执行此操作时:

object SingleTest extends PlaySpecification {
  "logging in" should {
    "fail with bad credentials" in {
      1 mustEqual 1
    }
  }
}

在scala我们被宠坏了“???”对于尚未实施的任何事情。但是,当我尝试这样做时,它会抛出这个错误:

Error:(28, 37) could not find implicit value for evidence parameter of type org.specs2.main.CommandLineAsResult[Unit]
"fail with bad credentials" in ...

有没有解决方法,或者我应该习惯“1 mustEqual 1”?

感谢。

3 个答案:

答案 0 :(得分:1)

您还可以使用成功和失败关键字

"logging in" should {
    "fail with bad credentials" in {
        success
    }

   "another option for login" in  {
      failure("not implemented") 
   }
}

答案 1 :(得分:0)

根据this,您需要使用pendingUntilFixed。所以,使用你的代码:

object SingleTest extends PlaySpecification {
  "logging in" should {
    "fail with bad credentials" in {
      1 mustEqual 1
    }.pendingUntilFixed
  }
}

答案 2 :(得分:0)

像这样使用todo

object SingleTest extends PlaySpecification {
  "logging in" should {
    "fail with bad credentials" >> todo
  }
}