间歇性地,一些ScalaTest测试运行失败并出现这种矛盾的输出:
...
akka.pattern.AskTimeoutException: Timed out
at akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:334)
at akka.actor.Scheduler$$anon$11.run(Scheduler.scala:118)
at scala.concurrent.Future$InternalCallbackExecutor$.scala$concurrent$Future$InternalCallbackExecutor$$unbatchedExecute(Future.scala:694)
at scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:691)
at akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(Scheduler.scala:455)
at akka.actor.LightArrayRevolverScheduler$$anon$12.executeBucket$1(Scheduler.scala:407)
at akka.actor.LightArrayRevolverScheduler$$anon$12.nextTick(Scheduler.scala:411)
at akka.actor.LightArrayRevolverScheduler$$anon$12.run(Scheduler.scala:363)
at java.lang.Thread.run(Thread.java:744)
[error] Could not run test com.example.Spec: akka.pattern.AskTimeoutException: Timed out
...
[info] ScalaTest
[info] Run completed in 20 seconds, 772 milliseconds.
[info] Total number of tests run: 64
[info] Suites: completed 12, aborted 0
[info] Tests: succeeded 64, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[error] Error: Total 64, Failed 0, Errors 0, Passed 64
[error] Error during tests:
[error] com.example.Spec
[error] (price-finder/test:test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 78 s, completed Jul 24, 2014 12:37:10 PM
如何防止这些失败?如果测试代码成功,我不希望抛出的异常导致测试运行失败。
答案 0 :(得分:2)
ScalaTest本身不区分错误和失败。不过,Sbt和JUnit以及specs2一样。您是否有可能在混合中为不同的测试框架编写测试?特别是,com.example.Spec看起来像什么?