Skip to content

Commit

Permalink
Take into account duplicate FQN from theories
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Jul 21, 2024
1 parent 7f58c4f commit 502d71d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/Sample/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ namespace Sample;

public class UnitTest1
{
[Theory]
[InlineData(1)]
[InlineData(2)]
public void Test1(int value)
{
Assert.True(value > 0);
}

[Fact]
public void FailsOnce()
{
Expand Down
8 changes: 7 additions & 1 deletion src/dotnet-retest/RetestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ Dictionary<string, bool> GetTestResults(string path)
var isFailed = result.Attribute("outcome")?.Value == "Failed";
var method = doc.CssSelectElement($"UnitTest[id={id}] TestMethod");
Debug.Assert(method != null);
outcomes.Add($"{method.Attribute("className")?.Value}.{method.Attribute("name")?.Value}", isFailed);
// NOTE: we may have duplicate test FQN due to theories, which we'd run again in this case.
// Eventually, we might want to figure out how to filter theories in a cross-framework compatible
// way, but for now, filtering by FQN should be enough, even if not 100% optimal.
var fqn = $"{method.Attribute("className")?.Value}.{method.Attribute("name")?.Value}";
if (!outcomes.TryGetValue(fqn, out var wasFailed) || !wasFailed)
// Only change the outcome if it was not already failed
outcomes[fqn] = isFailed;
}
}
}
Expand Down

0 comments on commit 502d71d

Please sign in to comment.