bcalmac (9) [Avatar] Offline
#1
The test examples from "Testing with Spock" look pretty simple. I'm interested to see how Spock deals with real-life, more complicated testing scenarios. What are some open source projects that embraced Spock and would be a good showcase for Spock capabilities?
Kostis Kapelonis (55) [Avatar] Offline
#2
Hello

Chapter 3 of the book is actually an effort to present some more real-life examples. Have you looked at the nuclear reactor test?
https://github.com/kkapelon/java-testing-with-spock/blob/master/chapter3/src/test/groovy/com/manning/spock/chapter3/coolant2/ImprovedCoolantSensorSpec.groovy

It is very close to how a real Spock test would be written.

I also suppose you have seen the https://code.google.com/p/spock/wiki/WhoIsUsingSpock page.

Apart from the Groovy projects (that eat their own dog food) the most obvious high profile opensource project is Tapestry
Here is a small selection of their Spock tests.

https://github.com/apache/tapestry-5/tree/master/tapestry-ioc/src/test/groovy/ioc/specs

Asgard from Netflix is another example
https://github.com/Netflix/asgard/tree/master/test/unit/com/netflix/asgard

I have tried to find more open-source examples with a quick search, but most github projects are only experimenting with Spock. Some of them even use bad
practices that I mention as an anti-pattern in the book. So I would be very cautious with Spock tests found in the wild.

I will place a question in the Spock mailing list and get back to you with the results.

Hope that helps

Kostis
Kostis Kapelonis (55) [Avatar] Offline
#3
I asked also on the mailing list and Rob Fletcher (one of the Spock gurus) informed me that Spock is used in the MongoDB Java driver.

The code is available on Github

https://github.com/mongodb/mongo-java-driver/tree/master/driver-core/src/test/unit/com/mongodb/client/model

Because they have both JUnit and Spock tests, it is better to use the Github search interface.

https://github.com/mongodb/mongo-java-driver/search?q=Specification

I hope that I have answered your question smilie

Kostis