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
8 changes: 8 additions & 0 deletions src/NUnitTestAdapter/Seed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ public class Seed
internal static readonly TestProperty NUnitSeedProperty = TestProperty.Register(
"NUnit.Seed",
"Seed", typeof(string), TestPropertyAttributes.None, typeof(TestCase));

internal static readonly TestProperty NUnitClassName = TestProperty.Register(
"NUnit.ClassName",
"NUnit Class Name", typeof(string), TestPropertyAttributes.None, typeof(TestCase));

internal static readonly TestProperty NUnitMethodName = TestProperty.Register(
"NUnit.MethodName",
"NUnit Method Name", typeof(string), TestPropertyAttributes.None, typeof(TestCase));
}
2 changes: 2 additions & 0 deletions src/NUnitTestAdapter/TestConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ private TestCase MakeTestCaseFromDiscoveryNode(NUnitDiscoveryTestCase testNode)

testCase.AddTraitsFromTestNode(testNode, TraitsCache, _logger, adapterSettings);
testCase.SetPropertyValue(Seed.NUnitSeedProperty, testNode.Seed.ToString());
testCase.SetPropertyValue(Seed.NUnitClassName, testNode.ClassName);
testCase.SetPropertyValue(Seed.NUnitMethodName, testNode.MethodName);
Comment thread
OsirisTerje marked this conversation as resolved.
Resolved

return testCase;

Expand Down
2 changes: 2 additions & 0 deletions src/NUnitTestAdapter/TestConverterForXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ private TestCase MakeTestCaseFromXmlNode(NUnitEventTestCase testNode)
}

testCase.AddTraitsFromXmlTestNode(testNode, TraitsCache, _logger, adapterSettings);
testCase.SetPropertyValue(Seed.NUnitClassName, testNode.ClassName);
testCase.SetPropertyValue(Seed.NUnitMethodName, testNode.MethodName);
Comment thread
OsirisTerje marked this conversation as resolved.
Resolved

return testCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.Testing.Platform.Extensions.TestFramework;
using Microsoft.Testing.Platform.Messages;
using Microsoft.Testing.Platform.TestHost;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;

namespace NUnit.VisualStudio.TestAdapter.TestingPlatformAdapter
Expand Down Expand Up @@ -56,6 +57,16 @@ public NUnitBridgedTestFramework(

protected override bool UseFullyQualifiedNameAsTestNodeUid => true;

protected override void AddAdditionalProperties(TestNode testNode, TestCase testCase)
{
var className = testCase.GetPropertyValue<string>(Seed.NUnitClassName, null);
var methodName = testCase.GetPropertyValue<string>(Seed.NUnitMethodName, null);
if (className is null || methodName is null)
return;
var property = TestMethodIdentifierBuilder.Create(testCase.Source, className, methodName);
testNode.Properties.Add(property);
}

/// <inheritdoc />
protected override Task SynchronizedDiscoverTestsAsync(
VSTestDiscoverTestExecutionRequest request,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Reflection;

using Microsoft.Testing.Platform.Extensions.Messages;

namespace NUnit.VisualStudio.TestAdapter.TestingPlatformAdapter;

internal static class TestMethodIdentifierBuilder
{
public static TestMethodIdentifierProperty Create(string assemblyPath, string className, string methodName)
{
var assemblyFullName = AssemblyName.GetAssemblyName(assemblyPath).FullName;
var dot = className.LastIndexOf('.');
var ns = dot >= 0 ? className.Substring(0, dot) : string.Empty;
var typeName = dot >= 0 ? className.Substring(dot + 1) : className;

return new TestMethodIdentifierProperty(
assemblyFullName,
ns,
typeName,
methodName,
methodArity: 0,
parameterTypeFullNames: Array.Empty<string>(),
returnTypeFullName: "System.Void");
}
}
Comment thread
OsirisTerje marked this conversation as resolved.
Resolved
Loading