Skip to content

Remove MSTest.Assert.Extensions #15178

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

Merged
merged 15 commits into from
Jul 17, 2025
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
1 change: 0 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<FromP2P>true</FromP2P>
</ProjectReference>

<PackageReference Include="MSTest.Assert.Extensions" Version="$(MSTestAssertExtensionVersion)" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="Microsoft.CodeCoverage" Version="$(MicrosoftCodeCoverageVersion)" />
<!--
Expand Down
1 change: 0 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
in TestAssets.sln to allow running and debugging tests in that solution directly in VS without having to run them via AcceptanceTests. -->
<MSTestTestFrameworkVersion>3.9.3</MSTestTestFrameworkVersion>
<MSTestTestAdapterVersion>3.9.3</MSTestTestAdapterVersion>
<MSTestAssertExtensionVersion>1.0.3-preview</MSTestAssertExtensionVersion>
<XUnitFrameworkVersion>2.4.2</XUnitFrameworkVersion>
<XUnitAdapterVersion>2.4.5</XUnitAdapterVersion>
<XUnitConsoleRunnerVersion>2.4.2</XUnitConsoleRunnerVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\src\DataCollectors\Microsoft.TestPlatform.Extensions.EventLogCollector\Microsoft.TestPlatform.Extensions.EventLogCollector.csproj" SetTargetFramework="TargetFramework=$(NetFrameworkRunnerTargetFramework)" />
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestTestFrameworkVersion)" Condition=" '$(OS)' != 'Windows_NT' " />
</ItemGroup>

<!-- We build this only for net48, and it fails to skip this on Linux in Aracade otherwise. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using MSTest.TestFramework.AssertExtensions;

namespace TestPlatform.Common.UnitTests.ExtensionFramework;

[TestClass]
Expand Down Expand Up @@ -130,9 +128,9 @@ public void GetTestExtensionsInformationShouldNotAbortOnFaultyExtensions()
typeof(TestPluginDiscovererTests).Assembly.Location,
};

var testExtensions = TestPluginDiscoverer.GetTestExtensionsInformation<FaultyTestExecutorPluginInformation, ITestExecutor>(pathToExtensions);
_ = TestPluginDiscoverer.GetTestExtensionsInformation<FaultyTestExecutorPluginInformation, ITestExecutor>(pathToExtensions);

Assert.That.DoesNotThrow(() => TestPluginDiscoverer.GetTestExtensionsInformation<FaultyTestExecutorPluginInformation, ITestExecutor>(pathToExtensions));
_ = TestPluginDiscoverer.GetTestExtensionsInformation<FaultyTestExecutorPluginInformation, ITestExecutor>(pathToExtensions);
}

#region Implementations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using MSTest.TestFramework.AssertExtensions;

namespace Microsoft.TestPlatform.ObjectModel.UnitTests;

[TestClass]
Expand Down Expand Up @@ -172,9 +170,9 @@ public void RunConfigurationFromXmlThrowsSettingsExceptionIfBatchSizeIsInvalid()
</RunSettings>";


Assert.That.Throws<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml))
.WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value 'Foo' specified for 'BatchSize'.");
var exception = Assert.ThrowsExactly<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml));
Assert.AreEqual("Invalid settings 'RunConfiguration'. Invalid value 'Foo' specified for 'BatchSize'.", exception.Message);
}

[TestMethod]
Expand All @@ -189,9 +187,9 @@ public void RunConfigurationFromXmlThrowsSettingsExceptionIfTestSessionTimeoutIs
</RunSettings>";


Assert.That.Throws<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml))
.WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '-1' specified for 'TestSessionTimeout'.");
var exception = Assert.ThrowsExactly<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml));
Assert.AreEqual("Invalid settings 'RunConfiguration'. Invalid value '-1' specified for 'TestSessionTimeout'.", exception.Message);
}

[TestMethod]
Expand Down Expand Up @@ -221,9 +219,9 @@ public void RunConfigurationFromXmlThrowsSettingsExceptionIfExecutionThreadApart
</RunSettings>";


Assert.That.Throws<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml))
.WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value 'RandomValue' specified for 'ExecutionThreadApartmentState'.");
var exception = Assert.ThrowsExactly<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml));
Assert.AreEqual("Invalid settings 'RunConfiguration'. Invalid value 'RandomValue' specified for 'ExecutionThreadApartmentState'.", exception.Message);
}

[TestMethod]
Expand All @@ -237,9 +235,9 @@ public void RunConfigurationFromXmlThrowsSettingsExceptionIfBatchSizeIsNegativeI
</RunConfiguration>
</RunSettings>";

Assert.That.Throws<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml))
.WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '-10' specified for 'BatchSize'.");
var exception = Assert.ThrowsExactly<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml));
Assert.AreEqual("Invalid settings 'RunConfiguration'. Invalid value '-10' specified for 'BatchSize'.", exception.Message);
}

[DataRow(true)]
Expand Down Expand Up @@ -348,8 +346,8 @@ public void RunConfigurationShouldThrowSettingsExceptionIfResultsirectoryIsEmpty
</RunConfiguration>
</RunSettings>";

Assert.That.Throws<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml))
.WithExactMessage("Invalid settings 'RunConfiguration'. Invalid value '' specified for 'ResultsDirectory'.");
var exception = Assert.ThrowsExactly<SettingsException>(
() => XmlRunSettingsUtilities.GetRunConfigurationNode(settingsXml));
Assert.AreEqual("Invalid settings 'RunConfiguration'. Invalid value '' specified for 'ResultsDirectory'.", exception.Message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
using Microsoft.VisualStudio.TestPlatform.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using MSTest.TestFramework.AssertExtensions;

using OMResources = Microsoft.VisualStudio.TestPlatform.ObjectModel.Resources.CommonResources;

namespace Microsoft.TestPlatform.Utilities.UnitTests;
Expand Down Expand Up @@ -42,8 +40,8 @@ public void UpdateRunSettingsShouldThrowIfRunSettingsNodeDoesNotExist()

Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp");

Assert.That.Throws<XmlException>(action)
.WithMessage("An error occurred while loading the settings. Error: Could not find 'RunSettings' node..");
var exception = Assert.ThrowsExactly<XmlException>(action);
Assert.AreEqual("An error occurred while loading the settings. Error: Could not find 'RunSettings' node..", exception.Message);
}

[TestMethod]
Expand All @@ -54,8 +52,8 @@ public void UpdateRunSettingsShouldThrowIfPlatformNodeIsInvalid()

Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp");

Assert.That.Throws<XmlException>(action)
.WithMessage("An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'foo' specified for 'TargetPlatform'.");
var exception = Assert.ThrowsExactly<XmlException>(action);
Assert.AreEqual("An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'foo' specified for 'TargetPlatform'..", exception.Message);
}

[TestMethod]
Expand All @@ -66,8 +64,8 @@ public void UpdateRunSettingsShouldThrowIfFrameworkNodeIsInvalid()

Action action = () => InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(xmlDocument, Architecture.X86, Framework.DefaultFramework, "temp");

Assert.That.Throws<XmlException>(action)
.WithMessage("An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'foo' specified for 'TargetFrameworkVersion'.");
var exception = Assert.ThrowsExactly<XmlException>(action);
Assert.AreEqual("An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'foo' specified for 'TargetFrameworkVersion'..", exception.Message);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using Microsoft.VisualStudio.TestPlatform.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using MSTest.TestFramework.AssertExtensions;

namespace Microsoft.TestPlatform.Utilities.Tests;

[TestClass]
Expand Down Expand Up @@ -50,7 +48,8 @@ public void ImportShouldThrowIfNotLegacySettingsFile()
MSTestSettingsUtilities.Import(
"C:\\temp\\r.runsettings",
xmlDocument);
Assert.That.Throws<XmlException>(action).WithMessage("Unexpected settings file specified.");
var exception = Assert.ThrowsExactly<XmlException>(action);
Assert.AreEqual("Unexpected settings file specified.", exception.Message);
}

[TestMethod]
Expand All @@ -65,7 +64,8 @@ public void ImportShouldThrowIfDefaultRunSettingsIsIncorrect()
MSTestSettingsUtilities.Import(
"C:\\temp\\r.testsettings",
xmlDocument);
Assert.That.Throws<XmlException>(action).WithMessage("Could not find 'RunSettings' node.");
var exception = Assert.ThrowsExactly<XmlException>(action);
Assert.AreEqual("Could not find 'RunSettings' node.", exception.Message);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\SettingsMigrator\SettingsMigrator.csproj" />
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestTestFrameworkVersion)" Condition=" '$(OS)' != 'Windows_NT' " />
</ItemGroup>

<ItemGroup>
Expand Down