viernes, enero 24, 2014

Reporting JBehave results in AsciiDoc format.

JBehave is a framework for Behaviour-Driven Development (BDD). BDD is an evolution of test-driven development (TDD) and acceptance-test driven design, and is intended to make these practices more accessible and intuitive to newcomers and experts alike. The core of JBehave from the point of view of end users are user story files, where we define stories that our product should meet to validate that we are aligned with what our client wants. These stories are run every time a change has done in the project, so we can still ensure that nothing has been broken and we are still delivering the right thing. To validate this, a report is generated by JBehave so we can inspect the result of all stories and be sure that all is ok and if there is something wrong, which stories and why they have failed. By default the formats supported by JBehave are TXT, HTML or XML

With the advent of markup languages for writing documentation, it has sense to be able to embed this reports inside our documentation system, because the result of a build should be considered as documentation too so everyone involved directly or indirectly on the project can review the real state of the project. One of the trending markup language nowadays is AsciiDoc (and Asciidoctor). It is for this reason that I have developed a JBehave report extension so reports are written in AsciiDoc format and consequently be embedded inside another AsciiDoc document.

Let's see an example of a report generated using AsciiDoc reporter, then the report of story is included inside a master AsciiDoc document and finally rendered using Asciidoctor to HTML.

The first part of the document we can see the story that is being executed (calculator_mult_stories.story). Just below we can see the result of the story in one sentence and with an icon. In this case there is one failure in one step (see below) so an ambulance icon is used. If there would be no errors then a green rocket is used, and if any pending or ignored steps then a yellow lorry is used. After that, description, meta-information and narrative data about story is printed. Then given stories of this story is printed with the result of all of them. In this case one given story has been executed and his scenario has just passed correctly.

Note that you can navigate to the result of a given story by simply clicking on the link provided in Given Stories information section.

And the document continues with:

After user stories the scenarios of current story are printed with their results. In this example as in previous one note that examples are used and are shown as a table. Finally all steps executed with its result are printed. Note that the final step have just failed and the cause of the error is shown.

So as you can see you can embed test result inside another AsciiDoc document and make them look clear for anyone who wants to review the state of the project.

But now let's see how to use AsciiDoc reporter inside JBehave.

Reporter is released on bintray, so the first thing is to add as repository maven bintray.

Then we can add the dependency on our project:

And now we can configure StoryReporterBuilder with adoc format.

And that's all, now when you run JBehave your reports will appear on output directory as HTML or TXT but also  as AsciiDoc.

We keep learning,
He's the guy who's the talk of the town, with the restless gun, don't shoot broad out to fool him around (Lo chiamavano Trinità - Annibale E I Cantori Moderni)

7 comentarios:

rmannibucau dijo...


Cool feature, is it planned to do the same for cucumber-jvm and cukeinspace?

Unknown dijo...

Yes I am thinking to use similar layout for cucumber. But first I am going to focus on releasing asciidoctor 1.5.0, and then I will start with cucumber extensions, which I will need it for a demo of Arquillian / Arquillian-CuckesOnSpace

Unknown dijo...

Reporting JBehave results in AsciiDoc format : ambulance image and thumb up image not coming in report. Please Help.

Unknown dijo...

What version of asciidoctor are you using to render AsciiDoc to html?

yanmaneee dijo...

louboutin shoes
off white hoodie
jordan 6
nike 95
moncler coat
cheap nba jerseys
air max 270

yanmaneee dijo...

kyrie spongebob
longchamp handbags
nike shoes
moncler outlet
timberland boots
westbrook shoes
michael kors purses
fila shoes
yeezy boost 350
adidas ultra

Steven Salvatore dijo...

HP Officejet Pro x551dw Offline are available right here on our site. Buy original Hewlett Packard ink cartridges and enjoy clear and consistent printouts from your HP OfficeJet Pro X551dw.