简体   繁体   English

Spec2:如何查看失败的测试堆栈跟踪并解决找不到的“ parseBody”关键字

[英]Spec2 :how to see failing test stacktrace and resolve “parseBody” keyword not found

I need to know two things here : 我需要在这里知道两件事:
1. How to see the stacktrace of the failing test case? 1.如何查看失败的测试用例的堆栈跟踪? Right now I only see the line number it failed and the result. 现在,我只看到失败的行号和结果。 See the outcome of the test case below : 请参阅以下测试案例的结果:


x return status 200
[error]    '404' is not equal to '200' (LayoutControllerSpec.scala:20)
  1. My controller uses parseBody keyword to parse json provided by JacksonJsonSupport class. 我的控制器使用parseBody关键字来解析JacksonJsonSupport类提供的json。 how to write the test case for the action me below : 如何为下面的操作编写测试用例:

val create = post() {
      var layout:Layout = parsedBody.extract[Layout] //Layout is model class
      ....
}

Any help or ideas would be highly appreciated. 任何帮助或想法将不胜感激。 Thanks, PS: This code is written for scalatra framework using spec2 framework. 谢谢,PS:此代码是使用spec2框架为scalatra框架编写的。

Let's answer the first question here. 让我们在这里回答第一个问题。

You can use the failtrace argument to get a stacktrace for a failure 您可以使用failtrace参数获取失败的failtrace

sbt> test-only *MySpec* -- failtrace

See also this question . 另见这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM