Is documentation readable by non-programmers possible with Spock?
Asked Answered
M

3

7

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.

Musset answered 3/8, 2011 at 21:7 Comment(0)
Q
3

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

Quietly answered 4/8, 2011 at 23:7 Comment(3)
I've been using the commenting feature and was wondering how that became a part of the output. Thanks Peter!Musset
Looks like NFJS took down the pps attachment that you had there. I'll do some googling on researching extensions & reports. Any add'l info you may be able to provide would be great. Thanks again.Musset
The GitHub repo I've linked to above contains all the material from my latest talk, including the slides.Quietly
C
11

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.

Consol answered 12/9, 2013 at 19:57 Comment(3)
UPDATE: you don't need to download the jar, spock-reports is available from JCenter as a maven artifact.Consol
Hi There, I was wondering if there is a possibility to include console logs along with the spock reports. I am visualizing something like a expand button around when: then: tags and expanding these will display corresponding console logging if any. Also, I would like to contribute to this if it is possible to implement and moved to GIT.Directorate
please use Github for feature requests.Consol
Q
3

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

Quietly answered 4/8, 2011 at 23:7 Comment(3)
I've been using the commenting feature and was wondering how that became a part of the output. Thanks Peter!Musset
Looks like NFJS took down the pps attachment that you had there. I'll do some googling on researching extensions & reports. Any add'l info you may be able to provide would be great. Thanks again.Musset
The GitHub repo I've linked to above contains all the material from my latest talk, including the slides.Quietly
F
0

There are some great answers in here already, but if you want to keep your BDD definitions free from any plumbing whatsoever, you can take a look at pease, which will let you use Gherkin specification language with Spock.

Flophouse answered 9/10, 2015 at 10:56 Comment(1)
Unfortunately pease is now unmaintained: Pease is outdated and won't be further developed or maintained. My recommendation is to have a look at the cucumber-jvm project.Morgenthaler

© 2022 - 2024 — McMap. All rights reserved.