Skip to content

Commit 195ee1a

Browse files
committed
Add initial documentation for the AsciiDoc reporter
Issue: #54 Signed-off-by: Johannes Thorn <[email protected]>
1 parent 76dbcab commit 195ee1a

File tree

1 file changed

+83
-25
lines changed

1 file changed

+83
-25
lines changed

docs/report_generation.adoc

Lines changed: 83 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,32 @@
22

33
=== Plain Text Reports
44

5-
By default JGiven outputs plain text reports to the console when executed. To disable plain text reports set the following Java system property:
5+
By default, JGiven outputs plain text reports to the console when executed. To disable plain text reports set the following Java system property:
66

7-
[source,java]
7+
[source,properties]
88
----
99
jgiven.report.text=false
1010
----
1111

1212
=== JSON Reports
1313

14-
By default JGiven will generate JSON reports into the `jgiven-reports/json` directory. JGiven tries to autodetect when it is executed by the Maven surefire plugin and in that case generates the reports into `target/jgiven-reports/json`. To disable JSON report generation set the following Java system property:
14+
By default, JGiven will generate JSON reports into the `jgiven-reports/json` directory. JGiven tries to autodetect when it is executed by the Maven surefire plugin and in that case generates the reports into `target/jgiven-reports/json`. To disable JSON report generation set the following Java system property:
1515

16-
[source,java]
16+
[source,properties]
1717
----
1818
jgiven.report.enabled=false
1919
----
2020

2121
[NOTE]
2222
====
23-
In order to generate HTML reports, JSON reports are required.
23+
In order to generate HTML or AsciiDoc reports, JSON reports are required.
2424
====
2525

2626
==== Change report directory
2727

2828
If you want to change the `jgiven-reports/json` directory, respectively `target/jgiven-reports/json`, set the following Java system property:
2929

30-
31-
[source,java]
30+
[source,properties]
3231
----
3332
jgiven.report.dir=<targetDir>
3433
----
@@ -37,15 +36,18 @@ If JGiven is executed by the Maven surefire plugin, this can be done by the syst
3736

3837
[NOTE]
3938
====
40-
In case HTML Reports are being generated, the source directory for the JSON Reports needs to be set accordingly (see "HTML Report" for more).
39+
In case HTML or AsciiDoc reports are being generated,
40+
the source directory for the JSON reports needs to be set accordingly
41+
(see <<HTML Report>> or <<AsciiDoc Report>> for more).
4142
====
4243

43-
=== Dry Run
44+
==== Dry Run
45+
4446
There is a dry run option, which just generates a report without actually
4547
executing the code. This might be helpful to generate a test report quickly
4648
without having to wait for the tests to be executed.
4749

48-
[source,java]
50+
[source,properties]
4951
----
5052
jgiven.report.dry-run=true
5153
----
@@ -65,19 +67,36 @@ The report generator can be executed on the command line as
6567
follows (assuming that the `jgiven-core` and the `jgiven-html5-report` JAR
6668
and all required dependencies are on the Java CLASSPATH)
6769

68-
69-
[source,bash]
70+
[source,console]
7071
----
71-
java com.tngtech.jgiven.report.ReportGenerator \
72-
--format=html \
73-
[--sourceDir=<jsonreports>] \
74-
[--targetDir=<targetDir>] \
72+
$ java com.tngtech.jgiven.report.ReportGenerator \
73+
--format=html \
74+
[--sourceDir=<jsonreports>] \
75+
[--targetDir=<targetDir>] \
7576
----
7677

7778
To see the HTML report in action you can have a look at the
7879
https://jgiven.org/jgiven-report/html5/[HTML report of JGiven itself]
7980

80-
==== Maven
81+
=== AsciiDoc Report
82+
83+
To generate an AsciiDoc report you have to run the JGiven report generator with the `asciidoc` format option.
84+
The report generator can be executed on the command line as follows
85+
(assuming that the `jgiven-core` JAR and all required dependencies are on the Java CLASSPATH)
86+
87+
88+
[source,console]
89+
----
90+
$ java com.tngtech.jgiven.report.ReportGenerator \
91+
--format=asciidoc \
92+
[--sourceDir=<jsonreports>] \
93+
[--targetDir=<targetDir>]
94+
----
95+
96+
To see the AsciiDoc report in action you can have a look at the
97+
https://jgiven.org/jgiven-report/asciidoc/[AsciiDoc report of JGiven itself]
98+
99+
=== Maven Plugin
81100

82101
For Maven there exists a plugin that can be used as follows:
83102

@@ -113,7 +132,7 @@ All of them are optional.
113132
|Option |Description
114133

115134
|format
116-
|The format of the generated report. Can be _html_ or _text_. Default: _html_
135+
|The format of the generated report. Can be _html_, _text_ or _asciidoc_. Default: _html_
117136

118137
|title
119138
|The title of the generated report. Default: _JGiven Report_
@@ -137,14 +156,43 @@ All of them are optional.
137156

138157
Now run:
139158

140-
[source,bash]
159+
[source,console]
141160
----
142161
$ mvn verify
143162
----
144163

145-
HTML reports are then generated into the `target/jgiven-reports/html` directory. Note that the plugin relies on the existence of the JSON output, so if the property `jgiven.reports.enabled` was set to `false`, no output will be generated.
164+
HTML reports are then generated into the `target/jgiven-reports/html` directory.
165+
Note that the plugin relies on the existence of the JSON output,
166+
so if the property `jgiven.reports.enabled` was set to `false`,
167+
no output will be generated.
168+
169+
Use the following configuration to generate the AsciiDoc report instead of the HTML report.
170+
171+
[source,xml,subs="verbatim,attributes"]
172+
----
173+
<build>
174+
<plugins>
175+
<plugin>
176+
<groupId>com.tngtech.jgiven</groupId>
177+
<artifactId>jgiven-maven-plugin</artifactId>
178+
<version>{version}</version>
179+
<executions>
180+
<execution>
181+
<goals>
182+
<goal>report</goal>
183+
</goals>
184+
</execution>
185+
</executions>
186+
<configuration>
187+
<format>asciidoc</format>
188+
<outputDirectory>${project.build.directory}/jgiven-reports/asciidoc</outputDirectory>
189+
</configuration>
190+
</plugin>
191+
</plugins>
192+
</build>
193+
----
146194

147-
==== Gradle
195+
=== Gradle Plugin
148196

149197
There also exists a plugin for Gradle to make your life easier.
150198
Add the following plugins section to your `build.gradle` file or extend the one you have already accordingly:
@@ -173,17 +221,19 @@ buildscript {
173221
}
174222
175223
apply plugin: "com.tngtech.jgiven.gradle-plugin"
176-
177224
----
178225

179226
Now run:
180227

181-
[source,bash]
228+
[source,console]
182229
----
183230
$ gradle test jgivenTestReport
184231
----
185232

186-
HTML reports are then generated into the `build/reports/jgiven/test/html/` directory. Note that the plugin relies on the existence of the JSON output, so if the property `jgiven.reports.enabled` was set to `false`, no output will be generated.
233+
HTML reports are then generated into the `build/reports/jgiven/test/html/` directory.
234+
Note that the plugin relies on the existence of the JSON output,
235+
so if the property `jgiven.reports.enabled` was set to `false`,
236+
no output will be generated.
187237

188238
If you want that the HTML report is always generated after the tests
189239
have been executed, you can configure the `test` task in your Gradle
@@ -201,19 +251,27 @@ https://plugins.gradle.org/plugin/com.tngtech.jgiven.gradle-plugin
201251

202252
JGiven will optionally load a configuration properties file, defaulting to:
203253
`jgiven.properties`. The path to the configuration can be customized with the system property:
254+
204255
----
205256
jgiven.config.path
206257
----
258+
207259
The encoding for the file is assumed to be `UTF-8`, but can be customized with the system property:
260+
208261
----
209262
jgiven.config.charset
210263
----
264+
211265
The following can be defined in the properties file:
266+
267+
[source,properties]
212268
----
213269
jgiven.report.enabled=false
214270
jgiven.report.dir=<targetDir>
215271
jgiven.report.text=false
216-
jgiven.report.text.color
272+
jgiven.report.text.color=auto
217273
jgiven.report.filterStackTrace=true
274+
jgiven.report.dry-run=false
218275
----
276+
219277
Configuration defined via Java system properties will take precedence over values in the configuration file.

0 commit comments

Comments
 (0)