小智 8
我知道这个问题已经有一年了,但我们遇到了同样的问题.按照彼得的建议,我创建了一个Spock扩展(https://github.com/anotherchrisberry/spock-retry).
如果您有基本规范(我们的情况),您只需添加一个@RetryOnFailure注释:
@RetryOnFailure
class BaseFunctionalSpec extends Specification {
// all tests will execute up to two times before failing
}
Run Code Online (Sandbox Code Playgroud)
或者,您可以将其添加到特定功能:
class SomeSpec extends Specification {
@RetryOnFailure(times=3)
void 'test something that fails sporadically'() {
// will execute test up to three times before failing
}
}
Run Code Online (Sandbox Code Playgroud)