diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000000..e37e2798259 --- /dev/null +++ b/test/README.md @@ -0,0 +1,34 @@ +# .NET testing samples + +This directory contains minimal examples that demonstrate how to use common .NET testing frameworks with different test platforms. + +## MSTest + +The MSTest samples demonstrate the same test using two different test platforms: + +- [VSTest](mstest/vstest) +- [Microsoft.Testing.Platform](mstest/microsoft-testing-platform) + +### VSTest + +The VSTest sample uses MSTest with the VSTest platform. + +To run the sample from this directory: + +```bash +dotnet test mstest/vstest/MSTestVSTest.csproj +``` + +### Microsoft.Testing.Platform + +The Microsoft.Testing.Platform sample uses `MSTest.Sdk` and the MSTest runner based on Microsoft.Testing.Platform. + +To run the sample from this directory: + +```bash +dotnet test mstest/microsoft-testing-platform/MSTestMTP.csproj +``` + +Both samples contain the same minimal test so that the differences between the test platform configurations are easy to compare. + +Additional testing framework samples can be added in separate directories. diff --git a/test/mstest/microsoft-testing-platform/CalculatorTests.cs b/test/mstest/microsoft-testing-platform/CalculatorTests.cs new file mode 100644 index 00000000000..14752c125a8 --- /dev/null +++ b/test/mstest/microsoft-testing-platform/CalculatorTests.cs @@ -0,0 +1,13 @@ +namespace MSTestMTP; + +[TestClass] +public sealed class CalculatorTests +{ + [TestMethod] + public void Add_TwoNumbers_ReturnsExpectedSum() + { + int result = 2 + 3; + + Assert.AreEqual(5, result); + } +} \ No newline at end of file diff --git a/test/mstest/microsoft-testing-platform/MSTestMTP.csproj b/test/mstest/microsoft-testing-platform/MSTestMTP.csproj new file mode 100644 index 00000000000..9d39068639b --- /dev/null +++ b/test/mstest/microsoft-testing-platform/MSTestMTP.csproj @@ -0,0 +1,16 @@ + + + + net9.0 + microsoft_testing_platform + latest + enable + enable + + true + + + diff --git a/test/mstest/vstest/CalculatorTests.cs b/test/mstest/vstest/CalculatorTests.cs new file mode 100644 index 00000000000..59d89723be4 --- /dev/null +++ b/test/mstest/vstest/CalculatorTests.cs @@ -0,0 +1,13 @@ +namespace MSTestVSTest; + +[TestClass] +public sealed class CalculatorTests +{ + [TestMethod] + public void Add_TwoNumbers_ReturnsExpectedSum() + { + int result = 2 + 3; + + Assert.AreEqual(5, result); + } +} diff --git a/test/mstest/vstest/MSTestVSTest.csproj b/test/mstest/vstest/MSTestVSTest.csproj new file mode 100644 index 00000000000..d39687b5c57 --- /dev/null +++ b/test/mstest/vstest/MSTestVSTest.csproj @@ -0,0 +1,19 @@ + + + + net9.0 + latest + enable + enable + + + + + + + + + + + +