Is readable documentation possible with Spock?

So I recently got specifications and testing with tools like FitNesse and Spock.

I made the first hit at FitNesse, and it was one undocumented challenge after another. So, fortunately, I tripped over Spock and fell in love pretty quickly.

Speaking of which, one thing I preferred was the FitNesse documentation. He provided both code and a document for these tests.

Is there a way in Spock (with a plugin? / Out of the box?) To generate any type of human-readable documentation to show off to project managers / stakeholders?

+7
source share
3 answers

Spock allows you to add descriptions to blocks, for example:

when: "5 dollars are withdrawn from the account" account.withdraw(5) then: "3 dollars remain" account.balance == 3 

Until we use this information, it’s easy for you to access the extension (see link below). It remains to do this in order to turn it into a good report.

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

+3
source

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

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

You can download the jar from the reports directory, and then simply add it to your classpath. Run your tests, and in a “miraculous way” you will get reports generated in the build/spock-reports directory!

You can even provide your own CSS style sheets if you want to customize reports as described in README.

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

UPDATE

spock-reports are already available on Maven Central as well as JCenter .

+9
source

There are some excellent answers here, but if you want your BDD definitions to be free of any plumbing, you can take a look at pease , which allows you to use the Gherkin specification language with Spock.

0
source

All Articles