Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ internal sealed class FrameworkHandlerAdapter : IFrameworkHandle
private readonly CancellationToken _cancellationToken;
private readonly bool _isTrxEnabled;
private readonly MessageLoggerAdapter _comboMessageLogger;
private readonly string _testAssemblyPath;
private readonly INamedFeatureCapability? _namedFeatureCapability;
private readonly ICommandLineOptions _commandLineOptions;
private readonly IClientInfo _clientInfo;
Expand All @@ -59,17 +58,13 @@ public FrameworkHandlerAdapter(
}
else if (testAssemblyPaths.Length > 1)
{
_testAssemblyPath = testApplicationModuleInfo.GetCurrentTestApplicationFullPath();
string testAssemblyPath = testApplicationModuleInfo.GetCurrentTestApplicationFullPath();

if (!testAssemblyPaths.Contains(_testAssemblyPath))
if (!testAssemblyPaths.Contains(testAssemblyPath))
{
throw new ArgumentException("None of the test assemblies are the test application.");
}
}
else
{
_testAssemblyPath = testAssemblyPaths[0];
}

_namedFeatureCapability = namedFeatureCapability;
_commandLineOptions = commandLineOptions;
Expand Down Expand Up @@ -119,7 +114,7 @@ public void RecordEnd(TestCase testCase, TestOutcome outcome)

_cancellationToken.ThrowIfCancellationRequested();

testCase.FixUpTestCase(_testAssemblyPath);
testCase.FixUpTestCase();

// Forward call to VSTest
_frameworkHandle?.RecordEnd(testCase, outcome);
Expand All @@ -132,7 +127,7 @@ public void RecordResult(TestResult testResult)

_cancellationToken.ThrowIfCancellationRequested();

testResult.TestCase.FixUpTestCase(_testAssemblyPath);
testResult.TestCase.FixUpTestCase();

// Forward call to VSTest
_frameworkHandle?.RecordResult(testResult);
Expand All @@ -151,7 +146,7 @@ public void RecordStart(TestCase testCase)

_cancellationToken.ThrowIfCancellationRequested();

testCase.FixUpTestCase(_testAssemblyPath);
testCase.FixUpTestCase();

// Forward call to VSTest
_frameworkHandle?.RecordStart(testCase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,8 @@ private static void AddAssertDataToException(VSTestException exception, TestResu
}
}

internal static void FixUpTestCase(this TestCase testCase, string? testAssemblyPath = null)
internal static void FixUpTestCase(this TestCase testCase)
{
// To help framework authors using code generator, we replace the Source property of the test case with the
// test assembly path.
if (RoslynString.IsNullOrEmpty(testCase.Source) && !RoslynString.IsNullOrEmpty(testAssemblyPath))
{
testCase.Source = testAssemblyPath;
}

// Because this project is the actually registered test adapter, we need to replace test framework executor
// URI by ours.
if (!testCase.Properties.Any(x => x.Id == OriginalExecutorUriProperty.Id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ internal sealed class TestCaseDiscoverySinkAdapter : ITestCaseDiscoverySink
private readonly VSTestBridgedTestFrameworkBase _adapterExtension;
private readonly TestSessionContext _session;
private readonly CancellationToken _cancellationToken;
private readonly string? _testAssemblyPath;

public TestCaseDiscoverySinkAdapter(
VSTestBridgedTestFrameworkBase adapterExtension,
Expand All @@ -55,17 +54,13 @@ public TestCaseDiscoverySinkAdapter(
}
else if (testAssemblyPaths.Length > 1)
{
_testAssemblyPath = testApplicationModuleInfo.GetCurrentTestApplicationFullPath();
string testAssemblyPath = testApplicationModuleInfo.GetCurrentTestApplicationFullPath();

if (!testAssemblyPaths.Contains(_testAssemblyPath))
if (!testAssemblyPaths.Contains(testAssemblyPath))
{
throw new ArgumentException("None of the test assemblies are the test application.");
}
}
else
{
_testAssemblyPath = testAssemblyPaths[0];
}

_testCaseDiscoverySink = testCaseDiscoverySink;
_logger = loggerFactory.CreateLogger<TestCaseDiscoverySinkAdapter>();
Expand All @@ -86,7 +81,7 @@ public void SendTestCase(TestCase discoveredTest)

_cancellationToken.ThrowIfCancellationRequested();

discoveredTest.FixUpTestCase(_testAssemblyPath);
discoveredTest.FixUpTestCase();

// Forward call to VSTest
_testCaseDiscoverySink?.SendTestCase(discoveredTest);
Expand Down
Loading