You are here
Home > java > Core Java >

Spock Framework Tutorial: Writing Java Unit Tests with Groovy

Spock Framework Tutorial: Writing Java Unit Tests with Groovy

Spock Framework tutorial showing Groovy unit testing code, Java application testing, mocking, stubbing and data-driven testing.Writing unit tests is an important part of Java application development. JUnit and Mockito are commonly used for this purpose, but maintaining large test suites can sometimes become difficult. Test methods may contain repetitive setup code, complicated assertions, and several mocking statements.

Spock Framework offers another approach. It uses Groovy to provide a descriptive syntax for writing tests, along with built-in mocking, stubbing, interaction verification, and data-driven testing.

The interesting part is that you do not need to convert your Java application into Groovy. You can continue writing production code in Java and use Groovy only for test cases.

What Is Spock Framework?

Spock Framework is a testing and specification framework for Java and Groovy applications. It uses Groovy syntax to describe application behavior through readable test specifications. Its main features include Given-When-Then blocks, built-in mocks, stubs, spies, interaction testing, and data-driven tests. Spock 2.5 supports Groovy 6.0 and runs on the JUnit Platform.

Who Should Read this Spock Framework Tutorial?

This tutorial is intended for Java developers who:

  • Already understand basic Java programming and object-oriented concepts.
  • Have some experience with JUnit or Mockito.
  • Want to explore an alternative approach to Java unit testing.
  • Want to learn Groovy syntax for writing automated tests.

Technology versions used in this tutorial:

Technology Version
Java 25
Groovy 6.0.0
Spock Framework 2.5
Maven 3.9.9 or later

We will use Maven to configure the project and write test cases for ordinary Java classes. Spring Boot application-context and REST controller testing are covered separately in our practical Spring Boot testing tutorial.

What Is Spock Framework in detail?

Spock is an open-source testing and specification framework for Java and Groovy applications. It uses Groovy as its specification language and provides a structured way to describe expected application behavior.

Unlike a conventional Java unit test, a Spock specification reads more like a description of what an application should do.

For example, consider a requirement:

“When a customer requests the price of an existing product, the application should return its final price after applying the applicable discount.”

A Spock test can express this requirement as follows:

File: ProductPricingServiceSpec.groovy

def "should calculate final price for an existing product"() {

    given:
    def product = new Product(
            1L,
            "Keyboard",
            new BigDecimal("100.00")
    )

    when:
    def result = pricingService.finalPrice(1L)

    then:
    result == new BigDecimal("90.00")
}

The test method name describes the expected behavior. The given:, when:, and then: blocks separate preparation, execution, and verification.

Important features of Spock

Feature Purpose
Specification-based testing Organizes tests around application behavior
Given-When-Then Makes test cases easier to understand
Built-in mocking Creates mocks without requiring Mockito
Stubbing Defines responses for dependencies
Interaction testing Verifies method calls and arguments
Data-driven testing Tests multiple input combinations
Expressive assertions Provides detailed failure information

Spock 2.x uses the JUnit Platform as its execution infrastructure. This allows Spock tests to run through compatible JUnit Platform tooling. It does not mean that Spock specifications must be written using JUnit’s @Test annotation.

For more details, refer to the official Spock Framework documentation.

Spock vs JUnit and Mockito

JUnit and Mockito are established tools in the Java testing ecosystem. Spock provides an alternative, particularly when developers prefer readable specifications and built-in mocking.

Let’s compare them.

Feature JUnit 5 + Mockito Spock
Test language Java Groovy
Test structure Annotations and methods Specification blocks
Mock creation Mockito Built-in Mock()
Stubbing Mockito when().thenReturn() Spock >> operator
Interaction verification Mockito verify() Interaction expressions
Data-driven tests Parameterized tests where: blocks
Assertions JUnit assertions Groovy conditions
Spring integration Supported Supported through spock-spring

Example: Mocking with Mockito

A typical Mockito test might contain:

when(productRepository.findById(1L))
        .thenReturn(Optional.of(product));

verify(productRepository, times(1))
        .findById(1L);

Equivalent Spock syntax

1 * productRepository.findById(1L) >>
        Optional.of(product)

The Spock statement combines the expected invocation count and the configured return value.

Should you choose Spock or JUnit?

Choose JUnit and Mockito when your team already has a well-established Java testing setup and wants to continue using familiar Java syntax.

Choose Spock when you prefer behavior-oriented specifications, concise mocking syntax, and data-driven testing.

Spock is not a mandatory replacement for JUnit. Both approaches are useful, and the right choice depends on your team’s skills and project requirements.

Setting Up a Spock Project

To start using Spock, create a Maven project and add Groovy and Spock dependencies.

We will create a small Java project rather than a Spring Boot application. This keeps the examples focused on unit testing fundamentals.

Writing Spock Tests in Spring Tool Suite (STS)

If you are using Spring Tool Suite (STS) as your primary IDE, you may need to configure additional Groovy language support before writing Spock test cases.

STS provides Java and Spring development facilities, but Groovy editing support is provided separately through the Groovy-Eclipse plugin.

Installing Groovy-Eclipse enables features such as Groovy syntax highlighting, code completion, navigation, and compilation support inside STS.

We have covered the complete configuration process in our separate tutorial:

How to Write Groovy Code in STS: Groovy Support in STS to Create Spock Tests

This guide explains how to install Groovy-Eclipse, configure an existing Java project, create the src/test/groovy folder, and write your first Spock specification directly in STS.

Important: Groovy-Eclipse provides IDE support, whereas GMavenPlus handles Groovy test compilation during the Maven build. These are separate configurations.

Create the Maven project

Create a Maven project with the following basic structure:

spock-unit-testing-demo/
|
├── pom.xml
|
└── src/
    |
    ├── main/
    │   └── java/
    │       └── com/example/pricing/
    │           ├── Product.java
    │           ├── ProductRepository.java
    │           ├── DiscountPolicy.java
    │           ├── ProductPricingService.java
    │           ├── ProductNotFoundException.java
    │           └── PriceLabelFormatter.java
    |
    └── test/
        └── groovy/
            └── com/example/pricing/
                └── ProductPricingServiceSpec.groovy

Notice that production classes are stored under src/main/java, whereas Spock test classes are stored under src/test/groovy.

This separation allows us to write production code in Java and testing code in Groovy.

Add Maven dependencies

Open pom.xml and configure the following dependencies.

<properties>
    <maven.compiler.release>25</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <groovy.version>6.0.0</groovy.version>
    <spock.version>2.5-groovy-6.0</spock.version>
</properties>

<dependencies>

    <!-- Groovy 6 -->
    <dependency>
        <groupId>org.apache.groovy</groupId>
        <artifactId>groovy</artifactId>
        <version>${groovy.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- Spock Framework -->
    <dependency>
        <groupId>org.spockframework</groupId>
        <artifactId>spock-core</artifactId>
        <version>${spock.version}</version>
        <scope>test</scope>
    </dependency>

</dependencies>

Let’s understand the dependencies.

  • groovy: Provides the Groovy language runtime required by our test specifications.
  • spock-core: Provides the Spock Specification API, mocking capabilities, and testing engine.
  • maven.compiler.release: Configures Java compilation for Java 25.

The Spock dependency version includes groovy-6.0. This is important because Spock provides different artifacts for different Groovy major versions.

Configure GMavenPlus

Maven does not compile .groovy files automatically. We need a plugin that adds Groovy test sources and compiles them.

Add the following configuration inside the build section:

<build>
    <plugins>

        <!-- Java Compiler -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.16.0</version>
        </plugin>

        <!-- Groovy Compiler -->
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>5.1.0</version>

            <executions>
                <execution>
                    <goals>
                        <goal>addTestSources</goal>
                        <goal>compileTests</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <!-- Test Execution -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.6.1</version>

            <configuration>
                <includes>
                    <include>**/*Spec.class</include>
                </includes>
            </configuration>
        </plugin>

    </plugins>
</build>

The plugins perform three different tasks:

  1. Maven Compiler Plugin compiles Java source files.
  2. GMavenPlus compiles Groovy test files.
  3. Maven Surefire executes the test specifications through the JUnit Platform.

The *Spec pattern is important because our test classes use the Spock naming convention rather than the default JUnit test naming convention.

Note: The GMavenPlus 5.x generation is selected here because the project uses Groovy 6. Older GMavenPlus configurations should not be copied blindly into this setup.

Refresh the Maven project in Eclipse

If you are using Eclipse or Spring Tool Suite, follow these steps after saving pom.xml:

  1. Right-click the Maven project.
  2. Select Maven → Update Project.
  3. Select your project.
  4. Enable Force Update of Snapshots/Releases.
  5. Click OK.
  6. Wait for dependency downloads to complete.
  7. Check that the Groovy test source folder is recognized.

If Eclipse still shows unresolved Groovy imports, verify the Maven dependency tree and Groovy IDE support before modifying the test code.

During the companion project’s setup, if Eclipse displayed this error:

The import spock cannot be resolved

This message means the IDE cannot resolve the Spock classes. It does not by itself identify the exact cause. Check whether the Spock dependency was downloaded, whether Maven updated successfully, and whether the Groovy source folder is configured correctly.

Run the project

Execute the following command from the project root:

mvn clean test

Maven should compile the Java classes, compile the Groovy specifications, and execute the tests.

You can inspect the dependency tree with:

mvn dependency:tree -Dincludes=org.spockframework

The output should include:

org.spockframework:spock-core:jar:2.5-groovy-6.0:test

Spock Framework architecture showing Java production classes, Groovy test specifications, Spock Engine inside JUnit Platform, and test execution results.

Understanding Spock Specification

A Spock test class is called a Specification.

Every specification extends the spock.lang.Specification class.

For example:

import spock.lang.Specification

class ProductPricingServiceSpec extends Specification {

    def "should calculate product price"() {

        expect:
        100 - 10 == 90
    }
}

The Specification class provides the core functionality required to execute feature methods, perform assertions, create mocks, and organize test lifecycle methods.

What is a feature method?

A feature method is an individual test scenario inside a specification.

Unlike conventional Java test methods, Spock allows descriptive method names written as strings.

def "should return the discounted product price"() {

    expect:
    100 - 20 == 80
}

The method name explains the behavior being tested.

Feature methods are automatically discovered by the Spock engine.

Understanding the Spock lifecycle

Spock provides lifecycle methods that execute before and after feature methods.

Method Execution
setupSpec() Once before all feature methods in a specification
setup() Before every feature method
cleanup() After every feature method
cleanupSpec() Once after all feature methods

For example:

class ProductPricingServiceSpec extends Specification {

    def setup() {
        println "Preparing test data"
    }

    def cleanup() {
        println "Cleaning up test data"
    }

    def "first test"() {
        expect:
        10 > 5
    }

    def "second test"() {
        expect:
        20 > 10
    }
}

The setup() method executes before each feature method. Therefore, the preparation message is printed twice.

Spock creates a fresh specification instance for each feature method by default. Use @Shared only when data genuinely needs to be shared across feature methods.

Spock Framework architecture showing Java production classes, Groovy test specifications, Spock Engine inside JUnit Platform, and test execution results.

Understanding Given-When-Then Blocks

Given-When-Then is the most recognizable feature of Spock.

It divides a test into three logical sections:

Block Purpose
given: Prepare test data and dependencies
when: Execute the operation
then: Verify the expected behavior

Let’s understand these blocks using a practical example.

Given: Prepare test data

The given: block creates the objects required for the test.

given:
def product = new Product(
        1L,
        "Keyboard",
        new BigDecimal("100.00")
)

When: Execute the operation

The when: block calls the method being tested.

when:
def result = pricingService.finalPrice(1L)

Then: Verify the result

The then: block checks whether the expected result was returned.

then:
result == new BigDecimal("90.00")

Spock automatically treats ordinary expressions inside then: and expect: blocks as conditions. You generally do not need to write assert before every expression.

Complete example

def "should calculate discounted product price"() {

    given:
    def product = new Product(
            1L,
            "Keyboard",
            new BigDecimal("100.00")
    )

    when:
    def result = pricingService.finalPrice(1L)

    then:
    result == new BigDecimal("90.00")
}

This example assumes the service and its dependencies have already been configured. We will build the complete Java implementation in the next section.

Spock also supports expect: when the test only needs to evaluate a condition without a separate action and verification section.

def "should verify basic price calculation"() {

    expect:
    new BigDecimal("100.00")
            .subtract(new BigDecimal("10.00")) ==
            new BigDecimal("90.00")
}

Mocking, Stubbing and Spying

Spock provides built-in support for mocks, stubs, and spies. You do not need Mockito to use these basic features.

To demonstrate them, let’s create a small Java pricing application.

Create the Java model

File: Product.java

package com.example.pricing;

import java.math.BigDecimal;

public record Product(
        long id,
        String name,
        BigDecimal price
) {
}

The Product record represents a product with an ID, name, and price.

File: ProductRepository.java

package com.example.pricing;

import java.util.Optional;

public interface ProductRepository {

    Optional<Product> findById(long id);
}

This interface defines the repository operation required by our pricing service.

File: DiscountPolicy.java

package com.example.pricing;

import java.math.BigDecimal;

public interface DiscountPolicy {

    BigDecimal discountRateFor(Product product);
}

The DiscountPolicy interface provides the applicable discount rate for a product.

Implement ProductPricingService

File: ProductPricingService.java

package com.example.pricing;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class ProductPricingService {

    private final ProductRepository productRepository;
    private final DiscountPolicy discountPolicy;

    public ProductPricingService(
            ProductRepository productRepository,
            DiscountPolicy discountPolicy) {

        this.productRepository = productRepository;
        this.discountPolicy = discountPolicy;
    }

    public BigDecimal finalPrice(long id) {

        Product product = productRepository.findById(id)
                .orElseThrow(
                    () -> new ProductNotFoundException(id)
                );

        BigDecimal discount =
                discountPolicy.discountRateFor(product);

        if (discount.compareTo(BigDecimal.ZERO) < 0 ||
                discount.compareTo(BigDecimal.ONE) > 0) {

            throw new IllegalArgumentException(
                    "Discount rate must be between 0 and 1"
            );
        }

        return product.price()
                .multiply(BigDecimal.ONE.subtract(discount))
                .setScale(2, RoundingMode.HALF_UP);
    }
}

File: ProductNotFoundException.java

package com.example.pricing;

public class ProductNotFoundException
        extends RuntimeException {

    public ProductNotFoundException(long id) {
        super("Product not found: " + id);
    }
}

Our service retrieves a product, obtains its discount rate, validates the rate, and calculates the final price.

For a product priced at 100.00 with a discount rate of 0.10, the expected price is 90.00.

We can now test this service using Spock.

Creating a Mock with Mock()

A mock is useful when we want to isolate the class being tested from its dependencies and verify interactions with those dependencies.

Spock provides the Mock() method for creating mock objects.

ProductRepository productRepository = Mock()
DiscountPolicy discountPolicy = Mock()

Let’s write a complete test.

File: ProductPricingServiceSpec.groovy

package com.example.pricing

import spock.lang.Specification

import java.math.BigDecimal
import java.util.Optional

class ProductPricingServiceSpec extends Specification {

    def "should calculate final price using mocked dependencies"() {

        given:
        def product = new Product(
                1L,
                "Keyboard",
                new BigDecimal("100.00")
        )

        ProductRepository repository = Mock()
        DiscountPolicy policy = Mock()

        def service = new ProductPricingService(
                repository,
                policy
        )

        when:
        def result = service.finalPrice(1L)

        then:
        1 * repository.findById(1L) >>
                Optional.of(product)

        1 * policy.discountRateFor(product) >>
                new BigDecimal("0.10")

        result == new BigDecimal("90.00")
    }
}

The following statement creates the mock:

ProductRepository repository = Mock()

The interaction:

1 * repository.findById(1L) >>
 Optional.of(product)

means that the repository method must be called exactly once with ID 1L, and it must return the specified product.

Similarly, the discount policy must be called once and return a discount rate of 0.10.

We are testing the pricing service without connecting to a real database or implementing an actual discount engine.

Creating a Stub with Stub()

A stub is useful when we only need a dependency to return predefined values.

Unlike a mock, a stub is not intended for verifying interaction counts.

For example:

DiscountPolicy discountPolicy = Stub()

discountPolicy.discountRateFor(_) >>
        new BigDecimal("0.15")

This tells Spock to return a discount rate of 15% whenever the method is called.

Let’s use it in a complete example.

def "should calculate price using stubbed discount policy"() {

    given:
    def product = new Product(
            1L,
            "Keyboard",
            new BigDecimal("200.00")
    )

    ProductRepository repository = Stub()
    repository.findById(1L) >> Optional.of(product)

    DiscountPolicy policy = Stub()
    policy.discountRateFor(_) >>
            new BigDecimal("0.15")

    def service = new ProductPricingService(
            repository,
            policy
    )

    when:
    def result = service.finalPrice(1L)

    then:
    result == new BigDecimal("170.00")
}

The product price is 200.00 and the stub returns a 15% discount. Therefore, the expected final price is 170.00.

Use stubs when the response matters but the number of method invocations does not.

Creating a Spy with Spy()

A spy wraps a real object and allows us to observe or override selected method behavior.

Let’s create a Java class that formats product prices.

File: PriceLabelFormatter.java

package com.example.pricing;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class PriceLabelFormatter {

    public String display(BigDecimal price) {
        return "Offer: " + format(price);
    }

    public String format(BigDecimal price) {

        return "INR " + price
                .setScale(2, RoundingMode.HALF_UP)
                .toPlainString();
    }
}

The display() method calls the format() method internally.

Now let’s use a Spock spy.

def "should use real formatter while overriding format method"() {

    given:
    PriceLabelFormatter formatter = Spy()

    when:
    def result = formatter.display(
            new BigDecimal("99.00")
    )

    then:
    1 * formatter.format({
        it.compareTo(new BigDecimal("99.00")) == 0
    }) >> "INR 99.00"

    result == "Offer: INR 99.00"
}

Here, Spock executes the real display() method but intercepts the call to format().

We override the result of format() for this test.

Spies are useful when you need to test a real object while controlling or observing selected internal interactions. However, avoid relying heavily on spies because they can make tests more dependent on implementation details.

Mock vs Stub vs Spy

Feature Mock Stub Spy
Creates a test double Yes Yes Wraps a real object
Provides configured responses Yes Yes Yes
Verifies interactions Yes No Yes
Executes real methods by default No No Yes
Typical use Collaboration testing Supplying test data Partial observation or override

Interaction-Based Testing

Interaction-based testing verifies how objects communicate with each other.

Sometimes checking the final return value is not enough. You may also need to verify that a dependency was called the expected number of times.

Spock provides a compact interaction syntax.

Verify a method is called exactly once

then:
1 * productRepository.findById(1L)

The number before the multiplication symbol specifies the expected invocation count.

Expression Meaning
1 * service.method() Exactly one invocation
2 * service.method() Exactly two invocations
0 * service.method() No invocations
1..3 * service.method() Between one and three invocations
_ * service.method() Any number of invocations

Verify method arguments

You can use exact values when the expected arguments are known.

1 * productRepository.findById(10L)

You can also use the wildcard _ when the exact argument is not important.

1 * productRepository.findById(_)

For more complex conditions, use an argument constraint.

1 * auditService.record({
  it.productId() == 10L
})

The closure checks whether the supplied argument satisfies the condition.

Prevent unexpected interactions

Suppose a pricing service should retrieve a product and obtain its discount, but should not call any additional mock methods.

You can use:

then:
1 * repository.findById(1L) >>
        Optional.of(product)

1 * policy.discountRateFor(product) >>
        new BigDecimal("0.10")

0 * _

The final statement rejects any additional interactions with the mocks in that feature method.

Use strict interaction verification when the interactions are part of the behavior you want to protect. Do not apply it automatically to every test, as it can make tests unnecessarily sensitive to internal refactoring.

Data-Driven Testing Using where:

Data-driven testing allows us to execute the same test method with multiple input values.

Spock provides the where: block for this purpose.

Instead of writing several similar test methods, we can define different inputs in a single feature method.

Testing multiple discount rates

Consider our ProductPricingService.

We want to test the following scenarios:

Original price Discount Expected price
100.00 0% 100.00
100.00 10% 90.00
100.00 25% 75.00
100.00 50% 50.00
100.00 100% 0.00

We can implement all these scenarios using one Spock feature method.

def "should calculate final price for different discount rates"() {

    given:
    def product = new Product(
            1L,
            "Keyboard",
            new BigDecimal("100.00")
    )

    ProductRepository repository = Stub()
    repository.findById(1L) >> Optional.of(product)

    DiscountPolicy policy = Stub()
    policy.discountRateFor(product) >> discountRate

    def service = new ProductPricingService(
            repository,
            policy
    )

    when:
    def result = service.finalPrice(1L)

    then:
    result == expectedPrice

    where:
    discountRate                  | expectedPrice
    new BigDecimal("0.00")        | new BigDecimal("100.00")
    new BigDecimal("0.10")        | new BigDecimal("90.00")
    new BigDecimal("0.25")        | new BigDecimal("75.00")
    new BigDecimal("0.50")        | new BigDecimal("50.00")
    new BigDecimal("1.00")        | new BigDecimal("0.00")
}

The where: block contains the test data.

Spock executes the feature method once for each row. In this example, the method has five iterations.

This is especially useful when testing calculations, validation rules, boundary conditions, and business logic.

Testing invalid discount rates

We can also use data-driven testing to verify that invalid discount rates are rejected.

def "should reject invalid discount rates"() {

    given:
    def product = new Product(
            1L,
            "Keyboard",
            new BigDecimal("100.00")
    )

    ProductRepository repository = Stub()
    repository.findById(1L) >> Optional.of(product)

    DiscountPolicy policy = Stub()
    policy.discountRateFor(product) >> discountRate

    def service = new ProductPricingService(
            repository,
            policy
    )

    when:
    service.finalPrice(1L)

    then:
    thrown(IllegalArgumentException)

    where:
    discountRate << [
        new BigDecimal("-0.10"),
        new BigDecimal("1.10"),
        new BigDecimal("2.00")
    ]
}

Each supplied discount rate should result in an IllegalArgumentException.

This is a good example of how Spock reduces repetitive testing code while keeping individual scenarios easy to understand.

Best Practices for Writing Spock Tests

Here are some practical recommendations for maintaining readable Spock specifications.

Use descriptive feature method names

Prefer:

def "should reject reservation when stock is insufficient"()

Instead of:

def "testReservation"()

A descriptive method name makes it easier to understand test reports.

Keep each test focused

A feature method should verify one behavior or a closely related set of conditions.

Avoid combining unrelated scenarios into one large specification.

Choose the right test double

Use:

  • Mock() when you need to verify interactions.
  • Stub() when you only need predefined responses.
  • Spy() when you need to observe or override selected behavior of a real object.

Prefer data-driven testing for repetitive scenarios

If the same method needs to be tested against several inputs, consider using a where: block.

It makes the test easier to extend when additional scenarios are introduced.

Avoid excessive interaction verification

Verify interactions that represent important application behavior.

Do not verify every internal method call. Excessive interaction checks can make tests fail after harmless implementation changes.

Keep production code in Java

There is no requirement to write your application in Groovy.

Use Java for business logic and Groovy for Spock specifications if that is the language combination your team prefers.

Run the complete test suite regularly

Execute:

mvn clean test

Do not rely only on running individual test classes from the IDE. The Maven build also checks whether the project configuration can compile and discover the specifications.

Conclusion

Spock Framework provides a different way of writing unit tests for Java applications. Its Groovy-based syntax makes specifications readable, while its built-in mocking and data-driven testing features reduce repetitive code.

Here are the key points from this tutorial:

  • Spock can test Java applications without converting production code to Groovy.
  • Every Spock specification extends spock.lang.Specification.
  • Given-When-Then blocks organize test scenarios.
  • Mock(), Stub(), and Spy() serve different testing purposes.
  • Interaction-based testing verifies method calls and arguments.
  • The where: block supports data-driven testing.
  • Spock 2.5 supports the Groovy 6.0 variant.

If you are already using JUnit and Mockito, you do not need to migrate your entire test suite immediately. Start with one Java service, write a few Spock specifications, and compare the readability and maintenance effort.

For Spring Boot developers, the next step is to understand how Spock integrates with the Spring application context and how to test REST controllers using MockMvc.

Read our companion tutorial: Testing Spring Boot Applications with Spock: A Practical Integration Testing Guide

Official Documentation and References
  1. Spock Framework 2.5 Reference Documentation
  2. Spock Framework 2.5 Release Notes
  3. Spock Framework GitHub Repository
  4. Apache Groovy Documentation
  5. GMavenPlus Plugin Documentation
  6. Maven Surefire Plugin Documentation

 

Leave a Reply



Top