如何抑制Cucumber / Junit断言堆栈跟踪 [英] How to suppress Cucumber/Junit assertion stack trace

查看:112
本文介绍了如何抑制Cucumber / Junit断言堆栈跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个解决方案,该步骤使用 assertEquals 。我的结果报告显示了对最终用户不友好的堆栈跟踪。我该如何抑制它?

I have a cucumber scenario and the step uses assertEquals. My results report shows the stack trace which is not end user friendly. How can I suppress it

  Scenario: Add two numbers
    Given I have two inputs "3" and "2"
    When I add them
    Then the output should be "15"

< img src = https://i.stack.imgur.com/gZKQT.png alt = junit>

推荐答案

您可以正确地观察到Junit测试中的默认XML输出(假设您没有输出到JSON或文本,但是您没有说)显示了失败步骤的堆栈跟踪。这实际上不是黄瓜。 CucumberOptions 不会在这里为您提供帮助。

You're correct in observing that the default XML output (assuming you're not outputting to JSON or text, but you didn't say) from a Junit tests show stack traces for failed steps. This isn't actually a Cucumber thing. CucumberOptions won't help you here.

您可以:


  1. 使用其他或自定义的Runner进行测试,然后设置一个标签,以控制输出中包含的内容或 CI软件。例如,执行此操作的Confulence API API会说明调试器

  2. Ant Script调整交易的交易类型,因此不会显示输出。 此处

  3. 其他人通过实现XMLJUnitResultFormatter API ,在此处进行了详细说明-如何配置JUnit Ant任务以仅在失败时产生输出?

  1. Use a different or custom Runner for your test and then setup a tag that controls what is included in the output, or what will be read by the CI software of your choosing. For example the Confulence API API for doing this tells how "debugger"
  2. Same type of deal for Ant Scripts to tweak the output, so that is doesn't show the output. A good Tutorial for learning how to use Any scripts to fire off your Cucumber JUnit Test is here.
  3. Other have build a custom formatter for JUnit by implementing XMLJUnitResultFormatter API, explained more here - How do I configure JUnit Ant task to only produce output on failures?

希望能为您提供所需的东西。

Hope that gives you what you need.

这篇关于如何抑制Cucumber / Junit断言堆栈跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆