Skip to content

Cannot use stubbed methods in cleanup method if the test succeeds #616

Description

@prismec

Issue description

I'm trying to use a stubbed method in a cleanup method. This works if an assertion failed in the test, but not if the test succeeds.

How to reproduce

class UseStubInCleanupSpec extends Specification {

    def mock = Mock(java.util.function.Function)

    def setup() {
        mock.apply("a") >> { "b" }
    }

    def cleanup() {
        assert mock.apply("a") == "b"
    }

    def "run a successful test"() {
        expect:
        true
    }

    def "run a failing test"() {
        expect:
        false
    }

}

Java/JDK

1.8

Groovy version

2.3.10:indy

Operating System

Mac

IDE

IntelliJ

Gradle/Grails

compile 'org.spockframework:spock 1.0-groovy-2.3'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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