1

当我运行以下测试时,它直接在描述子句中引发异常,然后到达 in 子句:

"when the message send actor receives a reference to an address" - {

        val unusedInThisTestActor = mock[ActorRef]
        val serviceFacade = testActor
        val keys = Array("password")
        val values =  Array("cheese")
        val addressRef = TestActorRef[ServiceEndpoint]

        val messageSender = system.actorOf(new Props(() => new MessageSendActor(unusedInThisTestActor, serviceFacade, unusedInThisTestActor)))
        messageSender ! ReferenceToAddress(addressRef, ("command", keys, values))

        "it tells the service facade to send the command to the address reference" in {
            expectMsg(SendCommandToService(addressRef,("command", keys, values)))
        }
    }

ScalaTest 然后忽略了这个测试,而不是说它失败了,这让每个人都认为代码工作正常。发现问题的唯一方法是仔细查看输出:

[ERROR] [06/16/2013 10:31:05.722] [main] [akka://testactorsystems/user/$$a] error while processing Create(622541251)
d7565b2b-b0a4-4af6-83c7-ed67f7bf0302akka.actor.ActorInitializationException: exception during creation
    at akka.actor.ActorInitializationException$.apply(Actor.scala:170)

并使用它来确定哪些测试没有运行。

这不是很有帮助,我更希望 scala 测试以某种方式将其标记为失败。那可能吗?

4

0 回答 0