Try
def "Does not provides specific failure"() {
expect:
with( testInstance ) {
trueParam
falseParam
}
}
سؤال
What I am trying to find is that if there is a way to identify the specific assert that caused the error when the asserts are inside a "with".
Ideally, I would like to see the same specific result for both tests.
The result of a given test is:
Condition not satisfied: testInstance.with { trueParam falseParam } | | | false SpockSpec$TestMe@1cf4af1e at SpockSpec.Does not provides specific failure(SpockSpec.groovy:10) Condition not satisfied: testInstance.falseParam // expected to fail | | | false SpockSpec$TestMe@24c2ffbc at SpockSpec.Provides specific failure(SpockSpec.groovy:19)
Code:
import spock.lang.Specification
import spock.lang.Unroll
@Unroll
class SpockSpec extends Specification {
def testInstance = new TestMe(trueParam: true, falseParam: false)
def "Does not provides specific failure"() {
expect:
testInstance.with {
trueParam
falseParam
}
}
def "Provides specific failure"() {
expect:
testInstance.trueParam
testInstance.falseParam // expected to fail
}
class TestMe {
boolean trueParam, falseParam
}
}
المحلول
Try
def "Does not provides specific failure"() {
expect:
with( testInstance ) {
trueParam
falseParam
}
}