CheckOps home

Tools directory

S

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.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

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

  1. Readable specifications: given/when/then blocks with implicit assertions.
  2. Data tables: where: blocks for concise parameterised tests.
  3. Built-in mocks: Mock, Stub and Spy with interaction counting.
  4. Power assertions: Detailed failure output for each sub-expression.

Pros

  1. Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 7 November 2026.
  3. Community: About 3,600 GitHub stars.

Cons

  1. Groovy required: Tests are written in Groovy, which adds a language and compiler to the build.
  2. Groovy version coupling: Spock artifacts are built per Groovy version.
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.

  1. Java and Groovy teams wanting expressive, data-driven tests with built-in mocking.
  2. 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.