Skip to content

Instantly share code, notes, and snippets.

@ddimtirov
Created June 4, 2017 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddimtirov/f1635ec9a77b8145ce10e52bef4e6047 to your computer and use it in GitHub Desktop.
Save ddimtirov/f1635ec9a77b8145ce10e52bef4e6047 to your computer and use it in GitHub Desktop.
Spock bug: bad assertion message
Condition not satisfied:
"""\ $a foobar covfefe """ == """ $b foobar covfefe """
|
false
Condition not satisfied:
x==y
|| |
|| 2 foobar
|| covfefe
||
|false
|1 difference (97% similarity)
| (1) foobar\n covfefe\n
| (2) foobar\n covfefe\n
1 foobar
covfefe
<Click to see difference>
import spock.lang.Specification
import spock.lang.Unroll
class MultilineStringSpec extends Specification {
@Unroll def "when/then - string literal outside 'then' #label"() {
when:
def x="""\
$a foobar
covfefe
"""
def y=""" $b foobar
covfefe
"""
then:
x==y
where:
a | b | label
1 | 1 | "success"
1 | 2 | "failure"
}
@Unroll def "when/then - string literal inside 'then' #label"() {
when: 'we move the string literal tot he assertion block'
System.currentTimeMillis()
then: 'same as above, just inlined'
"""\
$a foobar
covfefe
""" == """ $b foobar
covfefe
"""
where:
a | b | label
1 | 1 | "success"
1 | 2 | "failure"
}
@Unroll def "expect #label"() {
expect:
"""\
$a foobar
covfefe
"""==""" $b foobar
covfefe
"""
where:
a | b | label
1 | 1 | "success"
1 | 2 | "failure"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment