Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Experiment on adding events for onetimesetup/teardown #4690

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/NUnitFramework/framework/Internal/TestProgressReporter.cs
@@ -1,7 +1,9 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Xml;
Expand Down Expand Up @@ -77,6 +79,17 @@ private string CreateTestStartedMessage(ITest test)
{
writer.WriteAttributeString("framework-version", typeof(TestProgressReporter).Assembly.GetName().Version?.ToString());
}
if (test is TestSuite suite)
{
if (suite.OneTimeSetUpMethods.Any())
{
WriteOneTimeSetupTearDownElement(writer, suite.OneTimeSetUpMethods, "OneTimeSetup");
}
if (suite.OneTimeTearDownMethods.Any())
{
WriteOneTimeSetupTearDownElement(writer, suite.OneTimeTearDownMethods, "OneTimeTearDown");
}
}
}
else
{
Expand All @@ -90,6 +103,18 @@ private string CreateTestStartedMessage(ITest test)
return stringWriter.ToString();
}

private static void WriteOneTimeSetupTearDownElement(XmlWriter writer, IEnumerable<IMethodInfo> methods, string elementName)
{
writer.WriteStartElement(elementName);
foreach (var method in methods)
{
writer.WriteStartElement("method");
writer.WriteAttributeStringSafe("name", $"{method.TypeInfo.Name}.{method.Name}");
writer.WriteEndElement();
}
writer.WriteEndElement();
}

/// <summary>
/// Called when a test has finished. Sends a result summary to the callback.
/// </summary>
Expand Down