3

我在同一个类中有一系列测试都在测试相同的特性,我怎样才能跳过/忽略一个,例如:

class FooTest(_system: ActorSystem) extends TestKit(_system)
with ImplicitSender
with WordSpecLike
with Matchers
{
  implicit val timeout = Timeout(10.seconds)

  def this() = this(ActorSystem("TESTActorSystem"))

  "Service " should {
     "test something" in {
        OK
      }
    }
     "test to be ignored " in{
      "Not implemented" //ignore this test
      }
}

我确实使用registerIgnoredTest("test to be ignored")过,但我必须删除in. 有更优雅的解决方案吗?喜欢注释

4

1 回答 1

5

You are using WordSpecLike. In WordSpecLike, to ignore a test, you should change in into ignore like "test to be ignored " ignore {....

Different spec has different way to do it. If you were using FlatSpec, you could have annotated the with ignore should like ignore should "test to be ignored " in {....

You can see scalatest tagging section for more details.

于 2015-03-13T21:20:12.727 回答