Trace Timeline
' + renderSpanRows(sp, 't-' + rootSpanId) + '
';
}
@@ -1720,11 +1742,20 @@ function renderSuiteTrace(className) {
const allSpans = spansByTrace[suite.traceId];
if (!allSpans) return '';
const all = getDescendants(allSpans, suite.spanId);
- const testCaseIds = new Set();
- all.forEach(s => { if (s.spanType === 'test case') testCaseIds.add(s.spanId); });
- const tcDescendants = new Set();
- testCaseIds.forEach(id => { getDescendants(all, id).forEach(s => { if (s.spanId !== id) tcDescendants.add(s.spanId); }); });
- const filtered = all.filter(s => !tcDescendants.has(s.spanId) && !testCaseIds.has(s.spanId));
+ let filtered;
+ if (data.expandClassTimeline) {
+ // BDD/DependsOn mode: include test-case spans and their non-'test body' children
+ // so multi-step flows are visible at the class level.
+ filtered = collapseTestBodySpans(all);
+ } else {
+ // Default: drop test-case spans and their full subtrees so the class timeline
+ // shows only class-level infrastructure (suite, init/dispose, parallel coordination).
+ const testCaseIds = new Set();
+ all.forEach(s => { if (s.spanType === 'test case') testCaseIds.add(s.spanId); });
+ const tcDescendants = new Set();
+ testCaseIds.forEach(id => { getDescendants(all, id).forEach(s => { if (s.spanId !== id) tcDescendants.add(s.spanId); }); });
+ filtered = all.filter(s => !tcDescendants.has(s.spanId) && !testCaseIds.has(s.spanId));
+ }
// Include parent spans (assembly, session) for context
let ancestor = suite.parentSpanId ? bySpanId[suite.parentSpanId] : null;
while (ancestor) {
diff --git a/TUnit.Engine/Reporters/Html/HtmlReporter.cs b/TUnit.Engine/Reporters/Html/HtmlReporter.cs
index 5c3213503f..a8cf5898f0 100644
--- a/TUnit.Engine/Reporters/Html/HtmlReporter.cs
+++ b/TUnit.Engine/Reporters/Html/HtmlReporter.cs
@@ -1,4 +1,5 @@
using System.Collections.Concurrent;
+using System.Globalization;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -11,6 +12,7 @@
using Microsoft.Testing.Platform.Services;
using Microsoft.Testing.Platform.TestHost;
using TUnit.Core;
+using TUnit.Core.Settings;
using TUnit.Engine.Configuration;
using TUnit.Engine.Constants;
using TUnit.Engine.Exceptions;
@@ -336,7 +338,7 @@ private ReportData BuildReportData()
ClassName = kvp.Key,
Namespace = groupNamespaces.GetValueOrDefault(kvp.Key, ""),
Summary = groupSummary,
- Tests = kvp.Value.ToArray()
+ Tests = OrderTestsForDisplay(kvp.Value)
};
}
@@ -376,7 +378,8 @@ private ReportData BuildReportData()
CommitSha = commitSha,
Branch = branch,
PullRequestNumber = prNumber,
- RepositorySlug = repoSlug
+ RepositorySlug = repoSlug,
+ ExpandClassTimeline = TUnitSettings.Default.Report.ExpandClassTimeline,
};
}
@@ -465,6 +468,24 @@ internal static string[] FilterAdditionalTraceIds(string[] allTraceIds, string?
}
#endif
+ internal static ReportTestResult[] OrderTestsForDisplay(IEnumerable