Skip to content

Groovy with method bug fix in Spock 2.4-M7 #2269

@lukasgraef

Description

@lukasgraef

Describe the bug

I've stumbled over a possible regression in Spock 2.4-M7 when using Groovy's with{}-closure within a then: or expect: block.

The following two Reproducer tests both fail on M7 while both tests are working on M6.

To Reproduce

import spock.lang.Specification

class ReproducerSpec extends Specification {
    def "assert true in closure"() {
        expect:
        "foo".with {
            assert true
        }
    }

    def "return false in closure"() {
        expect:
        "bar".with {
            false
        }
    }
}

Expected behavior

I'm not sure whether the example above is a regression, because I think the behaviour in M7 (asserting the return value of with{}) seems more consistent than the previous behaviour. I just wanted to report this, as it breaks existing test cases, so this new behaviour should at least be clearly documented.

Actual behavior

Java version

Java 17

Buildtool version

Gradle 8.13

What operating system are you using

Windows

Dependencies

org.spockframework:spock-core:2.4-M7-groovy-3.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions