Repository navigation
chore: make retries work with custom timeouts - #2319
Max Schmitt (mxschmitt) wants to merge 6 commits into
Conversation
cc1f338 to
4e10690
Compare
|
|
||
| // 2.2 Wait for the test execution to complete (let e.g. Page.ClickAsync throw) | ||
| // and give the test 5 seconds to finish. | ||
| await Task.WhenAny(testExecutionTask, Task.Delay(5000)); |
There was a problem hiding this comment.
Drop this one please.
| { | ||
| foreach (var cleanupMethod in CleanupMethods) | ||
| { | ||
| await cleanupMethod(); |
There was a problem hiding this comment.
So this only cleans up our context, but does not run other [TestCleanup] methods. Is there a way to do that?
There was a problem hiding this comment.
Unfortunately not, since base.Execute(testMethod) already executes the TestInitialize and TestCleanup internally, so we can only execute it twice which we want to prevent. That's the reason for this custom new disposable layer called CleanupMethods.
92848cd to
9993077
Compare
| // 2. Close the BrowserContext | ||
| if (ContextCloseHookOnTimeout != null) | ||
| { | ||
| await ContextCloseHookOnTimeout().ConfigureAwait(false); |
There was a problem hiding this comment.
Would be nice to see some kind of cancellation of the close hook, but maybe I am overthinking it.
| public override TestResult[] Execute(ITestMethod testMethod) | ||
| { | ||
| var timeout = PlaywrightSettingsProvider.TestTimeout; | ||
| if (timeout == null || Debugger.IsAttached) |
There was a problem hiding this comment.
I get the intent of not timing out under debugger, but it makes it impossible to debug the timeout flow. It would be nice to have a ENV variable that you can set and make it go into the async flow. You will have to pump up your timeouts in the test if you want to be able to go step through it, but to me it looks useful when you are assisting someone with their issue related to timeouts.
But feel free to ignore my suggestions if you think feature creep is bigger issue than not being able to debug this.
There was a problem hiding this comment.
I'll follow-up.
| public async Task ContextTearDown() | ||
| { | ||
| await Context.CloseAsync().ConfigureAwait(false); | ||
| Context = null!; |
There was a problem hiding this comment.
I could not find why this is done, and it seems a bit obscure to force break your nullability. Are you checking it for null somewhere, or are you just trying to get it garbage collected earlier?
b8283b7 to
222a751
Compare
f1d3864 to
81d20ae
Compare
81d20ae to
9dae24d
Compare
Differences between NUnit and MSTest:
afterEachwhen a timeout is reached, this is not possible in MSTest since thebase.Execute()takes care of callingbeforeEach/afterEach.Both implementations will:
Relates #2316