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

Don't start thread/task when not using timeout for fixture methods #2825

Merged
merged 3 commits into from
May 7, 2024
Merged
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
15 changes: 12 additions & 3 deletions src/Adapter/MSTest.TestAdapter/Helpers/MethodRunner.cs
Original file line number Diff line number Diff line change
@@ -16,9 +16,18 @@ internal static class MethodRunner
internal static TestFailedException? RunWithTimeoutAndCancellation(
Action action, CancellationTokenSource cancellationTokenSource, int? timeout, MethodInfo methodInfo,
string methodCancelledMessageFormat, string methodTimedOutMessageFormat)
=> RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Thread.CurrentThread.GetApartmentState() == ApartmentState.STA
? RunWithTimeoutAndCancellationWithSTAThread(action, cancellationTokenSource, timeout, methodInfo, methodCancelledMessageFormat, methodTimedOutMessageFormat)
: RunWithTimeoutAndCancellationWithThreadPool(action, cancellationTokenSource, timeout, methodInfo, methodCancelledMessageFormat, methodTimedOutMessageFormat);
{
if (timeout is null)
{
action();
return null;
}

// We need to start a thread to handle "cancellation" and "timeout" scenarios.
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Thread.CurrentThread.GetApartmentState() == ApartmentState.STA
? RunWithTimeoutAndCancellationWithSTAThread(action, cancellationTokenSource, timeout, methodInfo, methodCancelledMessageFormat, methodTimedOutMessageFormat)
: RunWithTimeoutAndCancellationWithThreadPool(action, cancellationTokenSource, timeout, methodInfo, methodCancelledMessageFormat, methodTimedOutMessageFormat);
}

private static TestFailedException? RunWithTimeoutAndCancellationWithThreadPool(
Action action, CancellationTokenSource cancellationTokenSource, int? timeout, MethodInfo methodInfo,
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@
"commandLineArgs": "--treenode-filter /*/*/*/**"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Testing.Platform.Acceptance.IntegrationTests;
using Microsoft.Testing.Platform.Acceptance.IntegrationTests.Helpers;

namespace MSTest.Acceptance.IntegrationTests;

[TestGroup]
public sealed class ThreadContextTests : AcceptanceTestBase
{
private readonly TestAssetFixture _testAssetFixture;

public ThreadContextTests(ITestExecutionContext testExecutionContext, TestAssetFixture testAssetFixture)
: base(testExecutionContext)
{
_testAssetFixture = testAssetFixture;
}

[ArgumentsProvider(nameof(TargetFrameworks.All), typeof(TargetFrameworks))]
public async Task ThreadingContext_WhenCultureIsNotSet_TestMethodFails(string tfm)
{
var testHost = TestHost.LocateFrom(_testAssetFixture.ProjectPath, TestAssetFixture.ProjectName, tfm);
TestHostResult testHostResult = await testHost.ExecuteAsync();
testHostResult.AssertOutputContains("Failed: 1, Passed: 0, Skipped: 0, Total: 1");
}

[ArgumentsProvider(nameof(TargetFrameworks.All), typeof(TargetFrameworks))]
public async Task ThreadingContext_WhenChangedInAssemblyInitialize_IsPassedToTestMethod(string tfm)
=> await SetCultureInFixtureMethodAndRunTests(tfm, "MSTEST_TEST_SET_CULTURE_ASSEMBLY_INIT");

[ArgumentsProvider(nameof(TargetFrameworks.All), typeof(TargetFrameworks))]
public async Task ThreadingContext_WhenChangedInClassInitialize_IsPassedToTestMethod(string tfm)
=> await SetCultureInFixtureMethodAndRunTests(tfm, "MSTEST_TEST_SET_CULTURE_CLASS_INIT");

[ArgumentsProvider(nameof(TargetFrameworks.All), typeof(TargetFrameworks))]
public async Task ThreadingContext_WhenChangedInTestInitialize_IsPassedToTestMethod(string tfm)
=> await SetCultureInFixtureMethodAndRunTests(tfm, "MSTEST_TEST_SET_CULTURE_TEST_INIT");

private async Task SetCultureInFixtureMethodAndRunTests(string tfm, string envVarKey)
{
var testHost = TestHost.LocateFrom(_testAssetFixture.ProjectPath, TestAssetFixture.ProjectName, tfm);
TestHostResult testHostResult = await testHost.ExecuteAsync(environmentVariables: new() { [envVarKey] = "1" });
testHostResult.AssertExitCodeIs(0);
testHostResult.AssertOutputContains("Failed: 0, Passed: 1, Skipped: 0, Total: 1");
}

[TestFixture(TestFixtureSharingStrategy.PerTestGroup)]
public sealed class TestAssetFixture(AcceptanceFixture acceptanceFixture)
: TestAssetFixtureBase(acceptanceFixture.NuGetGlobalPackagesFolder)
{
public const string ProjectName = "ThreadContextProject";
private const string SourceCode = """
#file ThreadContextProject.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<EnableMSTestRunner>true</EnableMSTestRunner>
<TargetFrameworks>$TargetFrameworks$</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="$MSTestVersion$" />
<PackageReference Include="MSTest.TestFramework" Version="$MSTestVersion$" />
<PackageReference Include="Microsoft.Testing.Platform" Version="$MicrosoftTestingPlatformVersion$" />
</ItemGroup>
</Project>
#file UnitTest1.cs
namespace ThreadContextProject;
using System;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class UnitTest1
{
private const string CultureCodeName = "th-TH";
[AssemblyInitialize]
public static void AssemblyInitialize(TestContext context)
{
if (Environment.GetEnvironmentVariable("MSTEST_TEST_SET_CULTURE_ASSEMBLY_INIT") == "1")
{
CultureInfo.CurrentCulture = new CultureInfo(CultureCodeName);
}
}
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
if (Environment.GetEnvironmentVariable("MSTEST_TEST_SET_CULTURE_CLASS_INIT") == "1")
{
CultureInfo.CurrentCulture = new CultureInfo(CultureCodeName);
}
}
[TestInitialize]
public void TestInitialize()
{
if (Environment.GetEnvironmentVariable("MSTEST_TEST_SET_CULTURE_TEST_INIT") == "1")
{
CultureInfo.CurrentCulture = new CultureInfo(CultureCodeName);
}
}
[TestMethod]
public void TestMethod1()
{
Assert.AreEqual(CultureCodeName, CultureInfo.CurrentCulture.Name);
}
}
""";

public string ProjectPath => GetAssetPath(ProjectName);

public override IEnumerable<(string ID, string Name, string Code)> GetAssetsToGenerate()
{
yield return (ProjectName, ProjectName,
SourceCode
.PatchTargetFrameworks(TargetFrameworks.All)
.PatchCodeWithReplace("$MicrosoftTestingPlatformVersion$", MicrosoftTestingPlatformVersion)
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.AssemblyResolutionTests.AssemblyResolution_WhenNotSpecified_TestFails()
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.AssemblyResolutionTests.AssemblyResolution_WhenSpecified_TestSucceeds()
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.AssemblyResolverTests.RunningTests_DoesNotHitResourceRecursionIssueAndDoesNotCrashTheRunner()
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InitializeAndCleanupTimeout.AssemblyCleanup_WhenTimeoutExpires_AssemblyCleanupIsCancelled_AttributeTakesPrecedence(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InitializeAndCleanupTimeout.AssemblyCleanup_WhenTimeoutExpires_AssemblyCleanupIsCancelled_AttributeTakesPrecedence(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InitializeAndCleanupTimeout.AssemblyCleanup_WhenTimeoutExpires_AssemblyCleanupIsCancelled_AttributeTakesPrecedence(string) (net7.0)
@@ -135,6 +152,8 @@ MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.R
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_CentralPackageManagement_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Release)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_DotnetTest(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Debug)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_DotnetTest(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Release)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Debug)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Release)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone_Enable_Default_Extensions(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, bool) (disabled,Debug,CodeCoverage)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone_Enable_Default_Extensions(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, bool) (disabled,Release,CodeCoverage)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone_Enable_Default_Extensions(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, bool) (enabled,Debug,CodeCoverage)
@@ -151,8 +170,6 @@ MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.R
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone_Selectively_Enabled_Extensions(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, string, string, string) (multitfm,Release,HangDump)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone_Selectively_Enabled_Extensions(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, string, string, string) (multitfm,Release,Retry)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone_Selectively_Enabled_Extensions(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration, string, string, string) (multitfm,Release,TrxReport)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Debug)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_MSTestRunner_Standalone(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Release)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_VSTest(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Debug)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.SdkTests.RunTests_With_VSTest(string, Microsoft.Testing.TestInfrastructure.BuildConfiguration) (multitfm,Release)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.TestDiscoveryTests.DiscoverTests_FindsAllTests(string) (net462)
@@ -163,6 +180,22 @@ MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.TestDiscov
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.TestDiscoveryTests.DiscoverTests_WithFilter_FindsOnlyFilteredOnes(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.TestDiscoveryTests.DiscoverTests_WithFilter_FindsOnlyFilteredOnes(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.TestDiscoveryTests.DiscoverTests_WithFilter_FindsOnlyFilteredOnes(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInAssemblyInitialize_IsPassedToTestMethod(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInAssemblyInitialize_IsPassedToTestMethod(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInAssemblyInitialize_IsPassedToTestMethod(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInAssemblyInitialize_IsPassedToTestMethod(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInClassInitialize_IsPassedToTestMethod(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInClassInitialize_IsPassedToTestMethod(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInClassInitialize_IsPassedToTestMethod(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInClassInitialize_IsPassedToTestMethod(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInTestInitialize_IsPassedToTestMethod(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInTestInitialize_IsPassedToTestMethod(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInTestInitialize_IsPassedToTestMethod(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenChangedInTestInitialize_IsPassedToTestMethod(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenCultureIsNotSet_TestMethodFails(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenCultureIsNotSet_TestMethodFails(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenCultureIsNotSet_TestMethodFails(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadContextTests.ThreadingContext_WhenCultureIsNotSet_TestMethodFails(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadingTests.LifecycleAttributesTaskThreading_WhenMainIsNotSTA_RunsettingsAsksForSTA_OnWindows_ThreadIsSTA(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadingTests.LifecycleAttributesTaskThreading_WhenMainIsNotSTA_RunsettingsAsksForSTA_OnWindows_ThreadIsSTA(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadingTests.LifecycleAttributesTaskThreading_WhenMainIsNotSTA_RunsettingsAsksForSTA_OnWindows_ThreadIsSTA(string) (net7.0)
@@ -203,20 +236,3 @@ MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadingT
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadingTests.TestMethodThreading_WhenMainIsNotSTA_RunsettingsAsksForSTA_OnWindows_ThreadIsSTA(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ThreadingTests.TestMethodThreading_WhenMainIsNotSTA_RunsettingsAsksForSTA_OnWindows_ThreadIsSTA(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.ValueTaskTests.CanUseValueTaskForAllKnownLocations()
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.InfoTests.UsingInfoArgument_OutputCorrectVersionForMSTest(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithoutSettingConsiderEmptyDataSourceAsInconclusive_Fails(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusive_Passes(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net462)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net6.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net7.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.DynamicDataTests.SendingEmptyDataToDynamicDataTest_WithSettingConsiderEmptyDataSourceAsInconclusiveToFalse_Fails(string) (net8.0)
MSTest.Acceptance.IntegrationTests.MSTest.Acceptance.IntegrationTests.AssemblyResolverTests.RunningTests_DoesNotHitResourceRecursionIssueAndDoesNotCrashTheRunner()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Globalization;
@@ -511,12 +511,7 @@ public void TestInitialize_WhenTestReturnsTaskFromException_DisplayProperExcepti
_testClassInfo.TestInitializeMethod.Name,
"System.Exception: Outer ---> System.InvalidOperationException: Inner");
Verify(expectedErrorMessage == exception.Message);

#if NETFRAMEWORK
Verify(exception.StackTraceInformation is null);
#else
Verify(exception.StackTraceInformation is null);
#endif
Verify(exception.StackTraceInformation is not null);
}

public void TestMethodInfoInvokeWhenTestThrowsAssertFailReturnsExpectedResult()
@@ -614,17 +609,10 @@ public void TestCleanup_WhenTestReturnsTaskFromException_DisplayProperException(
"System.Exception: Outer ---> System.InvalidOperationException: Inner");
Verify(errorMessage == exception.Message);

#if NETFRAMEWORK
if (exception.StackTraceInformation != null)
if (exception.StackTraceInformation is null)
{
throw new Exception($"Expected stack trace to be empty.");
throw new Exception("Expected stack trace not to be empty.");
}
#else
if (exception.StackTraceInformation != null)
{
throw new Exception($"Expected stack trace to be empty.");
}
#endif
}

public void TestMethodInfoInvokeShouldCallTestCleanup()