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