Stylizing JBehave Reports

TERACytE picture TERACytE · Mar 9, 2012 · Viewed 8.7k times · Source

I am creating a collection of JBehave reports during my build that I would like to enhance. The default html reports that JBehave generates are very bland and could be tweaked for easier readability on my wiki when I post them for my customers. I would like to add some simple styling via css. However, I cannot find any examples on how to accomplish this.

Does anyone know how I can apply a custom css style to JBehave reports?

Here is how I'm generating the reports right now:

@Override
public Configuration configuration() {
    ...
    return new MostUsefulConfiguration()
            ....
            .useStoryReporterBuilder(new StoryReporterBuilder()
                    .withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
                .withFormats( Format.TXT,
                              Format.HTML)
                ...
            );
}

Answer

Brian Repko picture Brian Repko · Mar 13, 2012

A couple things - the StoryReporter captures events during story processing - in various formats. A JBehave "view" can be created from the reports. For example the Jenkins/Hudson plugins will use the XML reports directly. But you can create a website JBehave view using the default Freemarker templates, css/js resources. You can customize those to your hearts content.

Look at the section on "View Generation" on http://jbehave.org/reference/stable/reporting-stories.html - that will get you started - and there are examples in the JBehave examples for view generation.