【发布时间】:2018-02-09 06:19:35
【问题描述】:
这是有问题的代码块,在我的开发过程中,传递给它的响应在这一点上是无关紧要的,因为实际方法返回了一个不应通过的存根:
responseParser.parseErroredResponse(response)
.foreach {
failure => {
log.debug(s"$failure")
failure mustBe a[SubmissionFailure]
failure.message mustEqual "There is a syntax error in one of the queries in the AQuA input"
failure.code mustEqual "90005"
failure.names mustEqual Seq("Account", "AccountingPeriod", "NonExistent")
failure.queries mustEqual Seq(
"select Id from Account",
"select Id from AccountingPeriod",
"select non-existent from non-existent"
)
}
}
}
目前实际的ResponseParser.parseErroredResponse是这样的:
def parseErroredResponse(response: HttpResponse)
(implicit mat: ActorMaterializer,
ec: ExecutionContext): Future[SubmissionFailure] = {
Future(SubmissionFailure("", "", Seq(), Seq(), "", ""))
}
当我从 IntelliJ 和 SBT 运行测试时,我得到如下结果:
[info] - must parse a failed response and send a `SubmissionFailure` message
[ERROR] [02/08/2018 14:40:19.508] [test-system-akka.actor.default-dispatcher-4] [akka.dispatch.Dispatcher] "[]" did not equal "[There is a syntax error in one of the queries in the AQuA input]"
org.scalatest.exceptions.TestFailedException: "[]" did not equal "[There is a syntax error in one of the queries in the AQuA input]"
at org.scalatest.MatchersHelper$.indicateFailure(MatchersHelper.scala:340)
at org.scalatest.MustMatchers$AnyMustWrapper.mustEqual(MustMatchers.scala:6742)
at hydra.connectors.zuora.AquaActorSpec.$anonfun$new$16(AquaActorSpec.scala:265)
at scala.util.Success.foreach(Try.scala:249)
at scala.concurrent.Future.$anonfun$foreach$1$adapted(Future.scala:224)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:43)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
但它仍然显示为通过测试。我正在使用MustMatchers 特征进行断言,有什么想法可以解决这个测试失败吗?
【问题讨论】: