Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: remove dead SetSessionContext and update tests to use SetMessageBus
SetSessionContext(IMessageBus, SessionUid) was no longer called from
production code. Remove it and update HtmlReporterTests to call
SetMessageBus(bus) directly instead.

MTP auto-registers IDataConsumer via AddTestSessionLifetimeHandler, so
no AddDataConsumer registration is needed for HtmlReporter (adding one
would cause a "Consumer registered two time" crash).
  • Loading branch information
thomhurst committed Mar 27, 2026
commit 327d298f1b103c6db3d89886e4ba6935161c3893
6 changes: 2 additions & 4 deletions TUnit.Engine.Tests/HtmlReporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public async Task PublishArtifactAsync_Publishes_SessionFileArtifact_When_Sessio
// Arrange
var reporter = new HtmlReporter(new MockExtension());
var bus = new CapturingMessageBus();
var sessionUid = new Microsoft.Testing.Platform.TestHost.SessionUid("test-session-1");
reporter.SetSessionContext(bus, sessionUid);
reporter.SetMessageBus(bus);

var tempFile = Path.GetTempFileName();
try
Expand Down Expand Up @@ -92,8 +91,7 @@ public async Task PublishArtifactAsync_Is_NoOp_When_File_Does_Not_Exist()
{
var reporter = new HtmlReporter(new MockExtension());
var bus = new CapturingMessageBus();
var sessionUid = new Microsoft.Testing.Platform.TestHost.SessionUid("test-session-2");
reporter.SetSessionContext(bus, sessionUid);
reporter.SetMessageBus(bus);

await reporter.PublishArtifactAsync("/nonexistent/path/report.html", CancellationToken.None);

Expand Down
5 changes: 0 additions & 5 deletions TUnit.Engine/Reporters/Html/HtmlReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ internal void SetMessageBus(IMessageBus messageBus)
_messageBus = messageBus;
}

internal void SetSessionContext(IMessageBus messageBus, SessionUid sessionUid)
{
_messageBus = messageBus;
}

private ReportData BuildReportData()
{
var assemblyName = Assembly.GetEntryAssembly()?.GetName().Name ?? "TestResults";
Expand Down