【发布时间】:2020-08-15 10:07:58
【问题描述】:
Spockframework 提供了软断言机制,但它似乎无法正常工作(至少在我的配置中)。
我创建了最简单的测试:
verifyAll {
1 == 2
2 == 3
}
我希望看到两条失败消息,但我只看到第一条:
Condition not satisfied:
1 == 2
|
false
第二个也执行了,但是只出现在gradle report中:
org.example.SoftAssertionsTest > simplest test FAILED
org.spockframework.runtime.SpockComparisonFailure at SoftAssertionsTest.groovy:9
org.spockframework.runtime.SpockComparisonFailure at SoftAssertionsTest.groovy:10
版本:
compile 'org.codehaus.groovy:groovy-all:2.5.8'
testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation("org.springframework.boot:spring-boot-starter-test:2.+")
testImplementation('org.spockframework:spock-spring:1.3-groovy-2.5')
我已将此示例推送至:https://github.com/fergus-macdubh/spock-soft-assertions
有没有办法让它显示所有消息?
【问题讨论】:
-
如果 spock 在第一个错误后继续运行,我会感到非常惊讶。 not 快速失败的用例是什么?如果您想看到许多事情在同一个测试中快速失败,请查看表格和@Unroll 功能。
-
我无法重现您的问题,对我来说
verifyAll按预期工作。克隆 Gradle 项目时,我无法构建任何东西,似乎构建文件不完整并且没有定义目标。我是 Maven 人,所以我无法帮助修复您的 Gradle 构建。 -
@cfrick,
verifyAllSpock 确实会继续并评估所有条件。这是very purpose ofverifyAll。
标签: unit-testing testing groovy spock