CheckOps
Spock Framework
Spock is an Apache-2.0 BDD-style testing and specification framework for Java and Groovy applications, with given/when/then blocks, powerful data-driven tests and built-in mocking, running on the JUnit Platform.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
Spock describes itself as a BDD-style developer testing and specification framework for Java and Groovy applications. Specifications are written in Groovy, whose concise syntax makes tests expressive, while the code under test can be plain Java. Spock 2.x is based on the JUnit Platform, so it runs alongside JUnit 5 tests in Gradle and Maven, and it requires Java 8 or later and Groovy 2.5 or later (Groovy 3.0 or newer is recommended).
Each feature method is structured with labelled blocks (given:, when:, then:, expect:, where:), and every expression in a then: block is an implicit assertion, with “power assertion” output showing the value of each sub-expression on failure. Data-driven testing is a highlight: a where: block with a data table runs the feature once per row, and @Unroll-style naming (default in Spock 2) reports each iteration. Mocking and stubbing are built in (Mock(), Stub(), Spy()) with interaction checks such as 1 * repo.save(_). Extensions add timeouts, retries, conditional execution and Spring integration. Version 2.5 was released on 6 October 2026.
The source code is at spockframework/spock on GitHub under the Apache-2.0 licence, with about 3,600 stars; the most recent commit was on 7 November 2026.
Features
- Readable specifications: given/when/then blocks with implicit assertions.
- Data tables:
where:blocks for concise parameterised tests. - Built-in mocks: Mock, Stub and Spy with interaction counting.
- Power assertions: Detailed failure output for each sub-expression.
Pros
- Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 7 November 2026.
- Community: About 3,600 GitHub stars.
Cons
- Groovy required: Tests are written in Groovy, which adds a language and compiler to the build.
- Groovy version coupling: Spock artifacts are built per Groovy version.
Usage and Links (Example)
class DiscountSpec extends Specification {
def "applies #pct% discount to #price"() {
expect:
Pricing.apply(price, pct) == expected
where:
price | pct || expected
100 | 0 || 100
100 | 10 || 90
80 | 25 || 60
}
def "saves the order"() {
given:
def repo = Mock(OrderRepository)
def service = new OrderService(repo)
when:
service.place(new Order())
then:
1 * repo.save(_)
}
}
Resources:
Pricing
Spock Framework is free and open source under the Apache-2.0 licence.
Recommended for?
- Java and Groovy teams wanting expressive, data-driven tests with built-in mocking.
- Teams already using Gradle and Groovy.
Conclusion
Spock offers one of the most expressive testing experiences on the JVM, especially for data-driven tests, at the cost of adding Groovy.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with Spock Framework side by side.
JJUnit 5JUnit 5 is the current JUnit for Java and the JVM: Jupiter for new tests, Platform to launch them, Vintage to run JUnit 4.Compare with Spock Framework
TTestNGTestNG is an Apache-2.0 testing framework for Java, inspired by JUnit and NUnit, with annotations, groups, dependencies, data providers, parallel execution and XML suite configuration; it requires Java 11+.Compare with Spock Framework
MMockitoMockito is the MIT-licensed, most popular mocking framework for Java, used to create mocks, stubs and spies with a clean API; Mockito 5 uses the inline mock maker by default and requires Java 11.Compare with Spock Framework
KKotestKotest is an Apache-2.0 Kotlin multiplatform test framework with multiple testing styles, a large assertions library and built-in property-based testing.Compare with Spock Framework
AAssertJAssertJ is an Apache-2.0 fluent assertions library for Java, with rich, discoverable assertions for core types, collections, exceptions, dates and more, plus soft assertions and custom assertion generation.Compare with Spock Framework
CCucumberCucumber is the open-source BDD tool that runs Gherkin feature files against step definitions. It is not CucumberStudio.Compare with Spock Framework