Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is documentation readable by non-programmers possible with Spock?

FitNesse has a wiki-style documentation feature. It provided both the code and the doc's for these specification tests.

Is there a way in Spock (with plugin? / out of the box?) to generate any type of similar documentation to show off to the project managers / stakeholders, who can not be expected to read the (Groovy) source code of the Spock specifications.

like image 331
Lorin S. Avatar asked Aug 03 '11 21:08

Lorin S.


2 Answers

Well, I have used the Strings that describe each Spock block in your tests to generate HTML reports. Please visit my project and let me know if that helps:

https://github.com/renatoathaydes/spock-reports

You can download the jar from the reports directory and then just add it to your classpath. Run your tests, and "miraculously" you will have reports generated in the directory build/spock-reports!

You can even provide your own CSS stylesheets if you want to customize the reports, as explained in README.

Here's a blogpost I wrote about writing this Spock extension.

UPDATE

spock-reports has been available on Maven Central for a while now, as well as JCenter.

like image 135
Renato Avatar answered Nov 26 '22 08:11

Renato


Spock allows you to add descriptions to blocks, e.g.:

when: "5 dollars are withdrawn from the account"
account.withdraw(5)

then: "3 dollars remain"
account.balance == 3

While we don't use this information yet, it's easy to access from an extension (see link below). What's left to do is to turn this into a nice report.

https://github.com/spockframework/spock-uberconf-2011/blob/master/src/test/groovy/extension/custom/ReportExtension.groovy

like image 25
Peter Niederwieser Avatar answered Nov 26 '22 09:11

Peter Niederwieser