Basics
Q. What is the Spock web page?
A.
https://github.com/spockframework
Q. Where can I find examples of Spock code?
A.
https://github.com/spockframework/spock-example
Q. Where is the documentation?
A.
http://spockframework.github.io/spock/docs/1.0/index.html
Q. What is the Javadoc?
A.
http://spockframework.github.io/spock/javadoc/1.1-SNAPSHOT/index.html
Compatibility
Q. Can I add Spock tests to a
Java project that already has
JUnit tests?
A. Yes. JUnit tests are in src/test/java while Spock tests are in src/test/groovy
Q. Can I run Spock tests along with JUnit tests?
A. Yes they can both run at the same time. No need to throw away existing JUnit tests
Q. Can I use Spock with Intellij?
A. Yes. Spock using the same infrastructure as JUnit.
Q. Can I use Spock with Eclipse?
A. Yes. Spock using the same infrastructure as JUnit.
Q. Can I use Spock with
Maven?
A. Yes. Spock using the same infrastructure as JUnit.
Q. Can I use Spock with Gradle?
A. Yes. Spock using the same infrastructure as JUnit.
Q. Can I use Spock with
Jenkins?
A. Yes. Spock using the same infrastructure as JUnit.
Q. Can I use Spock with Sonar?
A. Yes you get code coverage like JUnit. (e.g. with Jacoco). Your Sonar can work with Spock out of the box.
Spock and Groovy
Q. Is Spock tied to Groovy?
A. No. Spock can
test Java code as well.
Q. Is Spock tied to Grails?
A. No. Spock can work with any Java project and technology.
Q. Is Spock tied to Gradle?
A. No, Spock works fine with Maven
Spock tests
Q. What is the characteristic of a Spock test class?
A. A class should extend spock.lang.Specification
Q. What is the characteristic of a Spock test method?
A. A Spock test method should have Spock blocks (given:, when:, then: etc)
Q. What is the programming language used in Spock tests?
A. Groovy. 99.9% of Java code is valid Groovy. This means that you can still use Java code in Spock tests.
Q. What is the naming scheme of Spock tests?
A. Most people name the tests with a *Spec ending. But this is for convenience. There is no technical requirement.
Integrations
Q. Can I use Spock and Spring?
A. Yes. There is an extension for this.
https://github.com/spockframework/spock/tree/master/spock-spring
Q. Can I use Spock and
Mockito?
A. In theory you could. But there is no need for this as Spock has its own mocking capabilities.
Q. Can I use Spock and Hamcrest matchers?
A. Yes. Here is an example
https://github.com/kkapelon/java-testing-with-spock/blob/master/chapter4/src/test/groovy/com/manning/spock/chapter4/structure/HamcrestMatchersSpec.groovy
Q. Can I use Spock and Guice?
A. Yes there is an extension for this
https://github.com/spockframework/spock/tree/master/spock-guice
Q. Can I use Spock and Arqullian?
A. Yes there is an extension for this.
https://github.com/arquillian/arquillian-testrunner-spock
And most importantly
Q. Where can I find a good book on Spock?
A. Here
https://www.manning.com/books/java-testing-with-spock
:-)