Skip to content

Spock assertion inside if-statement doesn't work #1160

@lipnitsk

Description

@lipnitsk

See this blog post for a thorough analysis of the issue.

Given test case:

def "should fail on expected == result comparison"() {
    given:
    def expected = "Hello, John!"

    when:
    def result = "Hello, Joe!"

    then:
    if (expected) {
        expected == result
    }
}

Expected result: FAIL
Actual result: PASS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions