Repository navigation
chore: add test retries - #2257
Conversation
a429b60 to
ec14992
Compare
| } | ||
|
|
||
| public TestContext? TestContext { get; set; } | ||
| public TestContext TestContext { get; set; } = null!; |
There was a problem hiding this comment.
drive-by fix.
| } | ||
|
|
||
| // https://github.com/microsoft/vstest/blob/200a783858425e5ac6f4ebb8f87a7811b0ad39e3/src/vstest.console/Internal/ConsoleLogger.cs#L319-L343 | ||
| function extractVstestMessages(stdout: string, prefix: string): string { |
There was a problem hiding this comment.
nunit/mstest or more in general the visual studio test platform will report the stdout/stderr after each test run with a prefix and two blank lines as a end. This parses them so we can easier process them. This seemed easier to trx, but can be changed most likely to get it from trx instead.
| catch (Exception ex) | ||
| { | ||
| context.CurrentResult = context.CurrentTest.MakeTestResult(); | ||
| context.CurrentResult.RecordException(ex); |
There was a problem hiding this comment.
Why do we have to handle this? I'd think that innerCommand should already do proper error reporting?
There was a problem hiding this comment.
Exception handling needs to be done manually, otherwise it throws and the parent method does catch it.
| while (Test2RetryCount[key] < PlaywrightSettingsProvider.Retries) | ||
| { | ||
| Test2RetryCount[key]++; | ||
| results = base.Execute(testMethod); |
There was a problem hiding this comment.
Shouldn't we append to results here, so that line 64 returns all results?
There was a problem hiding this comment.
After a discussion with pf we wanted to implemented for now a primitive approach, since if we return a failed test inside that list, it will result with exitCode 1 which we want to prevent.
| public static int Retries | ||
| { | ||
| get => _settings?.Retries ?? 0; | ||
| } |
There was a problem hiding this comment.
| public static int Retries | |
| { | |
| get => _settings?.Retries ?? 0; | |
| } | |
| public static int Retries => _settings?.Retries ?? 0; |
| @@ -57,6 +57,10 @@ public PlaywrightSettingsXml(XmlReader reader) | |||
| reader.Read(); | |||
| ExpectTimeout = float.Parse(reader.Value); | |||
There was a problem hiding this comment.
This will use the CurrentCulture is that intentional?
There was a problem hiding this comment.
seems unrelated to that PR do you mind filing an issue with more details or are you interested in contributing a fix to it?
8cd916d to
833dc8c
Compare
This PR adds the basic infra to implement retries inside the
Microsoft.Playwright.NUnitandMicrosoft.Playwright.MSTestharnesses. It's done via C# attributes which override the execution logic and re-runs it until the max-retries is reached or the test has passed.The. We now use Test Properties for it.Test2RetryCountdata structure is a naive way of sharing the retry-count with the actual test execution (by full classname/method name as a key), which is required for implementing screenshot/video/tracing on-first-retry (follow-up work)Follow-up work related to retries implementation:
[Test]and[PlaywrightTest]for NUnit, it looks like we run into this bug: NUnit v3 does not discover test when TestFixture inherits from class in different assembly nunit/nunit#2316 or Test not being recognised that have an attribute deriving from TestAttribute nunit/nunit#1347 so the users needs to either add[Test]and[PlaywrightTest]to their test or[TestFixture]to their class to workaround the discovery issue.Relates #2214
Example MSTest output
Example NUnit output