JBehave results displayed on a webpage

断了今生、忘了曾经 提交于 2019-12-11 21:25:58

问题


I have been working on a project that lets me test the behaviours of my companies webpage.

I have written an API and the testcase I am working on runs through JUnitRunner and the test passes.

The next step is to get the results displayed on a webpage, oes anyone know what plugin I need to get the JBehave results in HTML format or as a file.

I know I should be posting my code but there is no problems with the code, I just need the output in a different formatt.

Thanks


回答1:


To get the HTML output you need to make sure that you are generating the views with STATS and HTML output.

In MostUsefulConfiguration, add

    .useStoryReporterBuilder(
        new StoryReporterBuilder()
            .withReporters(new MyStoryReporter())
            .withFormats(Format.CONSOLE, Format.HTML, Format.STATS)

In the Embedder method add

    embedder = configuredEmbedder();
    embedder
         .embedderControls()
         .doGenerateViewAfterStories(true)

This should be all you need to do to get HTML output.

We wanted more information than is provided in the default output so we created a new StoryReporter class to capture the additional data and '@Override' the existing methods where appropriate. The new reporter class also needs to be added to the mostUseFulConfiguration

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

We also needed to amend or create a new Freemarker template (jbehave-reports-with-totals.ftl) to actually get it to write out the new data from the new story reporter class into an HTML file. I am not going to provide an example here. Please read the Freemarker documentation which is very good.




回答2:


check the reporting setup at JBehave's site.

and check the examples source code here. almost all examples is reporting to html and others.



来源:https://stackoverflow.com/questions/19587337/jbehave-results-displayed-on-a-webpage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!