In Spock Framework Tutorial you will learn how to write clear, readable, and powerful tests using fantastic Spock Framework!
The Basics
- Spock Framework Maven Gradle Setup
The best start is to configure Spock within your build tool of choice! - Groovy for Java Developers
Introduction to Groovy to get you started in just a few minutes!
Spock testing core
- Spock Framework basic test
Is the place where you should start your adventure with Spock Framework. - Spock Framework assert helper method
The example shows how to use helper methods to remove duplication from tests. - Spock Framework expect with where block
This example introduces powerful expect-where combo! - Spock Framework Given When Then Where
In which you will learn to use where blocks in flexible ways. - Spock Framework error reporting
Learn how to get feedback from tests even faster using @Unroll! - Spock Framework share object reuse
Learn how to reuse objects between tests using @Share!
Setup before and cleanup after test
- Spock Framework before after test
Find out how do setup/teardown before/after test! - Spock Framework before after class
How to do setup/teardown before/after Specification (class)? - AutoCleanup Spock test resources
Releasing test resources can be done in many ways. See how!
Mocking and Spying
- Spock Framework Mock
Mocking and interactions made easy! - Spock Framework Mock and Closures
Learn to write flexible tests with Groovy closures! - Spock Framework Mock throw exception
Learn how to use exceptions with Mocks! - Spock Spy and partial mocking
Practical example of partial mocking using Spy.
Other useful things to know
- Flexibly ignore tests in Spock
Learn how to execute tests depending on flexible conditions! - Documenting Spock Framework Tests
Increase readability of test reports!
Useful resources:
- Spock Framework Project Page
- Spock Framework Reference Documentation
- Java Testing with Spock by Konstantinos Kapelonis (AFAIK it’s the best book about Spock!)