2014-07-24 115 views
0

间歇一些ScalaTest测试运行失败,这种矛盾的输出:如何测试失败,既“TestsFailedException”和“0失败,错误0”

... 
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 

我怎样才能防止这些故障?如果测试代码成功,我不希望抛出的异常导致测试运行失败。

+1

“测试期间出错”与“失败测试”不同。这将有助于查看测试用例的相关部分。你实际上是否有64个测试或65个,还有一个没有被框架运行? – vptheron

+0

你的方向是对的。 Spec构造函数中有个例外。因此,尽管Spec中的所有测试都被实际跳过,但测试摘要不会显示它们。在“测试过程中的错误”中,我没有看到“错误”的含义。 –

+0

首先,你确定你正在从测试的线程中获得例外吗?因为如果不是这样,它将不会涓涓细流到测试,而是到另一个线程的顶部(很可能是来自ExecutionContext或Dispatcher的工作线程) –

回答

1

ScalaTest本身并不区分错误和失败。尽管如此,Sbt也如JUnit和specs2那样。是否有可能为混合中的不同测试框架编写测试?特别是,com.example是什么样的.Spec看起来像什么?

+0

没有使用其他测试框架。我的问题的答案似乎正如我评论的那样,一个测试类未能完全初始化。所以测试用例不会被加载并且似乎消失,而不是出现错误。 –

相关问题