gradle / test-retry-gradle-plugin

Gradle plugin to retry tests that have failed to mitigate test flakiness.
Apache License 2.0
222 stars 50 forks source link

question: is there a way to distinguish first run of a test and a retry? #180

Closed guai closed 1 year ago

guai commented 1 year ago

I want to test if this retrying work as expected before introducing it into my CI pipeline. So, I guess I need to emulate somehow a test failing on the first run and successful on any subsequent ones.

marcphilipp commented 1 year ago

This what we do in our own functional tests: https://github.com/gradle/test-retry-gradle-plugin/blob/f585427bfee334628ec140443e6a914db6091642/plugin/src/test/groovy/org/gradle/testretry/AbstractPluginFuncTest.groovy#L64-L80

You could do a simplified version of that that checks for the existence of a file and creates it in the first iteration but fails and passed in the second execution because the file already exists.