Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ private void AddOrUpdateTestNodeStateStatistics(TestNodeUid testNodeUid, bool ha
return;
}

if (existingStatistics.HasPassed == hasPassed)
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this is correct. Old code makes more sense to me.

If we receive two results, even if it's for the same test node, we should count it as two results.

It also doesn't make sense to gate the double counting under HasPassed == hasPassed.

If I have a folded test with two cases, imagine these two scenarios:

  • First case passed, second case failed -> we count it twice.
  • The two cases passed -> we count it once.

This doesn't make sense to me. I feel like the original issue is simply not correct and should just have been closed without making a change.

{
return;
}

if (hasPassed)
{
existingStatistics.TotalPassedRetries++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ public void PopulateTestNodeStatistics_WithDuplicatePassedEvents()
Assert.AreEqual(0, statistics.TotalDiscoveredTests);
Assert.AreEqual(1, statistics.TotalPassedTests);
Assert.AreEqual(0, statistics.TotalFailedTests);
Assert.AreEqual(1, statistics.TotalPassedRetries);
Assert.AreEqual(0, statistics.TotalPassedRetries);
Assert.AreEqual(0, statistics.TotalFailedRetries);
}

[TestMethod]
public void PopulateTestNodeStatistics_WithEventsForSameUid()
public void PopulateTestNodeStatistics_WithOutcomeChangeForSameUid_CountsAsRetry()
{
PropertyBag properties = new(
new FailedTestNodeStateProperty("failed"));
Expand All @@ -148,7 +148,7 @@ public void PopulateTestNodeStatistics_WithEventsForSameUid()
PropertyBag otherProperties = new(
PassedTestNodeStateProperty.CachedInstance);

TestNodeUpdateMessage otherTestNode = new(new SessionUid(string.Empty), new TestNode { Uid = new TestNodeUid("test()"), DisplayName = string.Empty, Properties = otherProperties });
TestNodeUpdateMessage otherTestNode = new(new SessionUid("2"), new TestNode { Uid = new TestNodeUid("test()"), DisplayName = string.Empty, Properties = otherProperties });

_service.PopulateTestNodeStatistics(testNode);
_service.PopulateTestNodeStatistics(otherTestNode);
Expand All @@ -161,6 +161,50 @@ public void PopulateTestNodeStatistics_WithEventsForSameUid()
Assert.AreEqual(0, statistics.TotalFailedRetries);
}

[TestMethod]
public void PopulateTestNodeStatistics_WithDuplicateFailedEvents_DoesNotCountAsRetry()
{
PropertyBag properties = new(
new FailedTestNodeStateProperty("failed"));

TestNodeUpdateMessage testNode = new(new SessionUid("1"), new TestNode { Uid = new TestNodeUid("test()"), DisplayName = string.Empty, Properties = properties });

_service.PopulateTestNodeStatistics(testNode);
_service.PopulateTestNodeStatistics(testNode);

TestNodeStatistics statistics = _service.GetTestNodeStatistics();
Assert.AreEqual(0, statistics.TotalDiscoveredTests);
Assert.AreEqual(0, statistics.TotalPassedTests);
Assert.AreEqual(1, statistics.TotalFailedTests);
Assert.AreEqual(0, statistics.TotalPassedRetries);
Assert.AreEqual(0, statistics.TotalFailedRetries);
}

[TestMethod]
public void PopulateTestNodeStatistics_WithDuplicateEventAfterOutcomeChange_OnlyCountsFirstRetry()
{
PropertyBag failedProperties = new(
new FailedTestNodeStateProperty("failed"));

TestNodeUpdateMessage failedTestNode = new(new SessionUid("1"), new TestNode { Uid = new TestNodeUid("test()"), DisplayName = string.Empty, Properties = failedProperties });

PropertyBag passedProperties = new(
PassedTestNodeStateProperty.CachedInstance);

TestNodeUpdateMessage passedTestNode = new(new SessionUid("1"), new TestNode { Uid = new TestNodeUid("test()"), DisplayName = string.Empty, Properties = passedProperties });

_service.PopulateTestNodeStatistics(failedTestNode);
_service.PopulateTestNodeStatistics(passedTestNode);
_service.PopulateTestNodeStatistics(passedTestNode);

TestNodeStatistics statistics = _service.GetTestNodeStatistics();
Assert.AreEqual(0, statistics.TotalDiscoveredTests);
Assert.AreEqual(1, statistics.TotalPassedTests);
Assert.AreEqual(0, statistics.TotalFailedTests);
Assert.AreEqual(1, statistics.TotalPassedRetries);
Assert.AreEqual(0, statistics.TotalFailedRetries);
}

[TestMethod]
public void PopulateTestNodeStatistics_WithEventsForDifferentUids()
{
Expand Down