gradle / test-retry-gradle-plugin

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

Run command before retry or before last retry #206

Open oeresundsgruppen opened 1 year ago

oeresundsgruppen commented 1 year ago

Would it be an idea to allow to run a command before a retry or before last retry, e.g. restart a service, reload db etc.

CommandBeforeRetry=sqlcmd delete from tableX CommandBeforeLastRetry=gradlew restartX && wait 60

Maybe I could add this and make PR for your review ?

oeresundsgruppen commented 1 year ago

This is beneficial when tests are not mackovian, e.g. they built up state...

pshevche commented 5 months ago

@oeresundsgruppen , thank you for reporting this proposal and volunteering to work on this. Could you help us understand the scenario better?

It seems like the class' lifecycle methods like JUnit's @BeforeEach or @BeforeAll would be a good place for such commands. Those will be executed before each retry, and you could then restart a service, etc.

Can you maybe give an example where this will not work?