Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format narrative in reports #289

Merged
merged 1 commit into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions jbehave-support-core/docs/Reporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public XmlReporterFactory xmlReporterFactory() {
Plus at least one [reporter extension](#reporter-extensions) (bean implementing a XmlReporterExtension interface).

The default generated XML report contains only information about:
- story narrative
- story start time
- story end time
- story duration
Expand All @@ -22,6 +23,14 @@ The default generated XML report contains only information about:

Rest of the information available in the report depends on the extensions used/registered.

In case you want to have narrative in report you have to follow JBehave narrative format:
```
In order to explain how to use narrative
As a development team
I want to show you how to do it
```
All three fixed part of narrative must be present in given order: `In order to`, `As a` and `I want to`

### Reporter extensions
The default report can be extended with other info by registering beans implementing the interface XmlReporterExtension
(for convenience an abstract class AbstractXmlReporterExtension containing methods for writing XML elements can be used).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,27 @@
<td colspan="2">Narrative:</td>
</tr>
<tr>
<td>- In order to:</td>
<td>
<xsl:value-of select="narrative/inOrderTo"/>
<td class="align-baseline">- In order to:</td>
<td class="align-baseline">
<xsl:call-template name="break">
<xsl:with-param name="text" select="narrative/inOrderTo" />
</xsl:call-template>
</td>
</tr>
<tr>
<td>- As a:</td>
<td>
<xsl:value-of select="narrative/asA"/>
<td class="align-baseline">- As a:</td>
<td class="align-baseline">
<xsl:call-template name="break">
<xsl:with-param name="text" select="narrative/asA" />
</xsl:call-template>
</td>
</tr>
<tr>
<td>- I want to:</td>
<td>
<xsl:value-of select="narrative/iWantTo"/>
<td class="align-baseline">- I want to:</td>
<td class="align-baseline">
<xsl:call-template name="break">
<xsl:with-param name="text" select="narrative/iWantTo" />
</xsl:call-template>
</td>
</tr>
</xsl:if>
Expand Down Expand Up @@ -387,4 +393,23 @@
</xsl:if>
</xsl:template>

<xsl:template name="break">
<xsl:param name="text" select="string(.)"/>
<xsl:choose>
<xsl:when test="contains($text, '&#xa;')">
<xsl:value-of select="substring-before($text, '&#xa;')"/>
<br/>
<xsl:call-template name="break">
<xsl:with-param
name="text"
select="substring-after($text, '&#xa;')"
/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Narrative:
This scenario is sample story for ServerLogXmlReporterExteson
In output we can se:
In order to explain how ServerLogReportExtension work
As a development team
I want to use different report modes in 3 stories
So you can se in output:
2X LONG_REPORTABLE (file) created from TEMPLATE and FULL mode
2X TEST created from CACHE and FULL mode

Expand Down