-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replay failed tests #212
Comments
@theredfish I'm not sure whether it has sense. Flaky tests should not be a common thing. In our codebases we actively reworking them to remove any flakiness, because it's very hard to reason about tests when you have the one: either a test fails due to flakinees, or the test may pass due to flakiness too. So I'm somewhat against about making life easier with flaky tests instead of giving people more reasons to remove it. Let's hear what other users think about it. |
@theredfish I do think, that adding retries for flaky tests is a great feature to have, but I have couple concerns about proposed implementation.
In addition to specifying number of times test should be retried, I think that we should retry only tests tagged as
I think, that this may lead to unexpected problems: on #[given(...)]
fn apply_then_assert(w: &mut World) {
w.counter += 1;
assert_eq!(w.counter, 3);
} Retrying this
I'm not sure this can be achieved with streaming output like ours. And even if it would, I think, that we should be transparent about failed flaky tests and also include stats about them in
I saw couple of conference talks, where people from huge |
@ilslv okay, I see that there are enough reasons for having this feature. Speaking of the feature design...
I think, both variants should be provided, so we have the natural tags inheritance:
I propose
The detailed summarization is "must have" 👍 Questions:
|
@tyranron I think that reasonable default should be rerunning |
@ilslv yup. It also worths to mark the retried scenarios explicitly in the output, like the following:
|
Thank you for the feedback! Indeed the idea isn't to encourage to ignore flaky tests but have a way to handle them waiting for a fix. The tag is a good idea so we offer a different granularity and an explicit way.
My bad it wasn't clear enough but my example was about scenarios not steps. I can try to implement this feature if you want ? If you're available to guide me during the development ? |
Actually
I'll be happy to help you with development of this feature! |
I was a bit busy with other projects, I'll start to work on it :) |
While implementing retries for failed We can use Another way to deal with this problem is to output retried ack @tyranron @theredfish |
That's great if you can do some progress on this feature, I haven't been able to work on it since my last commit. But I can continue later if you want. Just switching between priorities for the moment. With your current example how do you specify the number of attempts for a postponed retry? Do we remove the possibility to specify de number of attempts per Since postponed is a strategy selected by users, they should expect more delays, is it really an issue to have to wait more? It might even be intended to decouple the execution from the rest. Flaky tests can be due to side effects created by other tests for example. Regarding the delay if I understand it will block the execution until the delay is reached, but will execute the test asynchronously from the rest.
What do you mean by separate branch? From the execution flow? Then it will be a bit confusing with the existing feature replay_failed_tests no? What if we have both? Maybe we can keep a "naive" implementation first and then iterate? We could provide the immediate retry as a first solution, and later work around a postponed version where we can discuss more in depth of the different solutions. It will avoid to worry about the output and existing features. A retry with a delay is still a good idea I think, most of the time we need to wait a bit before retrying. We could then have only one default mode, if there is no delay we retry without one, if there is a delay we just wait during this time. As a first implementation it might be enough. Or we can reduce this first feature to only an immediate retry. Do we keep the number of attempts config? |
It means this.
No, the
Well, the delay for retry is a good feature to have. And having so much options to configure retrying, I think we need to revisit the Maybe, something like this?
So, the "postponed" case is handled by the optional Regarding the CLI option, we may:
The same goes for methods too. I'd like keeping them separate more.
After giving it quite a though, I see this as the only reasonable way. Retrying without giving explicit feedback about it is quite a subtle thing. We better notify explicitly about what's going on. Also, mentioning retries in the overall execution stats would be a very pleasant feature too. So I vote for re-outputting only. |
Clear understanding of what's going on is a very important thing for me too, but I think the clearest way of notifying about retries is doing it the closest to the error itself. I image it something like that:
Actually |
I don't mind.
But in case of |
@tyranron I think, that having 2 different behaviours for immediate and postponed retries may be confusing for the users, mostly because reasons behind it aren't obvious. Even we didn't see them through until the implementation came. I still think, that same
I expressed this concern before and I still think it's important, that this library should push users into using the best practices. So having a little bit of friction in a place, where user's tests are flaky and should be retried after a certain timeout is actually a good thing. Also I still have some questions about how separate |
Why not just output them as a regular error?
Agree.
So, could you sum up the whole feature design then? With the answers addressing the questions raised above in previous comments. |
@tyranron out of all upstream implementations only ruby and js have support for retrying scenarios:
And even those who implement are using only CLI flags (
Should we output only previous retry error or all of them? And I'm not sure how to communicate clearly, that it isn't a new error, just a re-outputted one.
I think we have a consensus on tags looking like
Alternatively you can overwrite number of retries for all scenarios via Regarding the output I think that clearest way to understand what's going on with the retries is shown here. This means not moving on to the next But I think that current implementation in #223 strikes a good balance between hanging output and actually seeing progress. This implementation doesn't move onto a next |
I think we should clearly output all the retry attempts and their results.
Haven't got it. What do you mean by "re-outputted"?
Yes, that's what I've thought of. But how do we resolve the issue with the stuck output in
This implies that
Actually, I liked the |
Whole discussion about
Thinking more and more about this, I think that we can ditch
Hm, I haven't thought about it, but this seems to be more useful, then previous meaning of
Actually I've already implemented more powerful feature, basically like |
I think that just print the error "as is" and later having the
I'm not against this. I've thought about it too.
That's OK, but the concern I've raised is not about power, but rather ergonomic and CLI. I could easily imagine the situation when someone wants to retry the test suite without populating |
Discussed with @tyranron:
Detailed explanation of interactions between CLI options and tagsLet's explore how different sets of CLI options would interact with the following Feature: Retries
@retry
Scenario: First
Given a moral dilemma
@flacky @retry(3)
Scenario: Second
Given a moral dilemma
@retry(4).after(5s)
Scenario: Third
Given a moral dilemma
Scenario: Fourth
Given a moral dilemma No CLI options at all
|
- add `--retry`, `--retry-after` and `--retry-tag-filter` CLI options - describe retrying in a separate Book chapter - add `writer::Stats::retried_steps()` method - wrap `event::Scenario` into `event::RetryableScenario` for storing in other `event`s Co-authored-by: Kai Ren <[email protected]>
@theredfish released in 0.14.0. |
I was wondering if it's something that we can add to the framework. We already have a function to repeat failed tests output but we don't have a function to run failed tests again. It's common to have flaky tests that sometimes can be solved by running them again.
For example :
Where 2 is the maximum number of times the tests should be run again in case of test failures. Let's say we have the tests
A
,B
,C
andD
:A
passesB
,C
andD
are run again (1 replay left if we have new test failures)C
andD
(0 replay left)D
fails again, this one is certainly more than just unstableRegarding the output we have two choices :
D
in this example)2
, or a previous run if all tests are passing)The text was updated successfully, but these errors were encountered: