Skip to content

Commit be5aef2

Browse files
rogeralsingclaude
andcommitted
Use live console output as fallback when TRX results are empty
If TRX parsing returns no results but we saw "Passed/Failed" in live console output, trust the live counts instead of marking batch as failed. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 6b39af1 commit be5aef2

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/Asynkron.TestRunner/IsolateRunner.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -798,16 +798,33 @@ private async Task<BatchRunResult> RunBatchAsync(TestBatch batch, bool suppressO
798798
reason = guardReason ?? "Batch terminated by guard";
799799
}
800800

801-
var hadResults = results.Count > 0;
801+
// Use live console output counts as fallback if TRX has no results
802+
var hadResults = results.Count > 0 && (passed.Count > 0 || failed.Count > 0);
803+
var hadLiveResults = testsPassed > 0 || testsFailed > 0;
802804

803-
if (!hadResults)
805+
if (!hadResults && hadLiveResults)
806+
{
807+
// TRX empty but we saw live output - trust the live counts
808+
// Create synthetic pass count based on live output
809+
hadResults = true;
810+
for (var i = 0; i < testsPassed; i++)
811+
{
812+
passed.Add($"live_test_{i}");
813+
}
814+
for (var i = 0; i < testsFailed; i++)
815+
{
816+
failed.Add($"live_failed_{i}");
817+
}
818+
}
819+
820+
if (!hadResults && !hadLiveResults)
804821
{
805822
var cmdName = isVsTest ? "dotnet vstest" : "dotnet test";
806823
reason = exitCode != 0
807824
? $"{cmdName} exited {exitCode} with no results (filter mismatch?)"
808825
: $"{cmdName} produced no results";
809826
}
810-
else if (exitCode != 0 && failed.Count == 0 && timedOut.Count == 0)
827+
else if (exitCode != 0 && failed.Count == 0 && timedOut.Count == 0 && !hung)
811828
{
812829
reason = $"exit code {exitCode} despite no failed/hanging tests";
813830
}

0 commit comments

Comments
 (0)