额外的记录JBehave [英] Additional logging JBehave

查看:190
本文介绍了额外的记录JBehave的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方案如下:

我们正在使用JBehave和Selenium进行系统,集成和端到端测试。
我正在检查超过20个值的页面上的计算结果以进行验证。
使用Junit断言整个测试将在其中一个值不正确的第一个实例上失败。我想要做的是,如果一个断言失败,那么测试继续执行,这样我就可以在一次测试运行中整理所有不正确的值,而不是多次测试运行。

We are using JBehave and Selenium for system, integration and end to end testing. I am checking the results of a calculation on a page with in excess of 20 values to validate. Using Junit Assert the entire test will fail on the first instance of one of the values being incorrect. What I wanted to do was that if an assertion failure is met then the test continues to execute so that I can then collate all of the values that are incorrect in one test run rather than multiple test runs.

为此,我捕获断言并将未经验证的任何内容写出到日志文件中。这给我留下了一些问题:

To do this I capture the assertions and write out to a log file anything that fails the validation. This has left me with a couple of issues:

1)我写出断言失败的日志文件不包含JBehave Story或Scenario的名称在发生异常时运行。

1) The log file where I write out the assertions failures do not contain the name of the JBehave Story or Scenario that was being run when the exception occurred.

2)JBehave故事或场景被列为通过,我希望它被列为失败。

2) The JBehave Story or Scenario is listed as having 'Passed' and I want it to be listed as 'Failed'.

有没有办法可以将Story和Scenario的名称记录到附加日志文件中,或者将其他日志记录写入JBehave日志文件?

Is there any way that I can either log the name of the Story and Scenario out to the additional log file OR get the additional logging written to the JBehave log file?

如何将Story / Scenario标记为失败?

How can I get the Story / Scenario marked as failed?

在JBehave配置中我有:

In the JBehave configuration I have:

configuredEmbedder()
    .embedderControls()
    .doIgnoreFailureInStories(true)
    .doIgnoreFailureInView(false)
    .doVerboseFailures(true)
    .useStoryTimeoutInSecs(appSet.getMaxRunningTime());

.useStoryReporterBuilder(
    new StoryReporterBuilder()
    .withDefaultFormats()
    .withViewResources(viewResources)
    .withFormats(Format.HTML, Format.CONSOLE)
    .withFailureTrace(true)
    .withFailureTraceCompression(true)
    .withRelativeDirectory("jbehave/" + appSet.getApplication())


推荐答案

是的,你可以创建自己的StoryReporter:

Yes, you can create your own StoryReporter:

 public class MyStoryReporter implements org.jbehave.core.reporters.StoryReporter{
     private Log log = ...

     @Override
     public void successful(String step) {
        log.info(">>successStep:" + step);
     }

    @Override
    public void failed(String step, Throwable cause) {
        log.error(">>error:" + step + ", reason:" + cause);
    }

     ...
 }

并按如下方式注册:

.useStoryReporterBuilder(
    new StoryReporterBuilder()
         .withReporters(new MyStoryReporter())
..

这篇关于额外的记录JBehave的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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