Update Mono.Linker.Tests to MSTest#126412
Conversation
|
Tagging subscribers to this area: @agocke, @dotnet/illink |
aba276c to
1323c8f
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Mono.Linker.Tests test project to use MSTest instead of NUnit.
Changes:
- Switches test framework attributes/usings from NUnit to MSTest across multiple test files.
- Updates test case data feeding from NUnit
TestCaseSource/TestCaseDatato MSTestDynamicData/DataRowpatterns. - Changes project configuration to use the MSTest test runner and updates assembly-level parallelization settings.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tools/illink/test/Trimming.Tests.Shared/TestCaseSandbox.cs | Updates documentation text to refer to MSTest instead of NUnit. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/TestFrameworkRulesAndConventions.cs | Converts fixture/method attributes to MSTest. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/PreserveActionComparisonTests.cs | Converts parameterized test attributes to MSTest DataRow. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/ParseResponseFileLinesTests.cs | Converts test attributes to MSTest. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/MessageContainerTests.cs | Converts test attributes/usings to MSTest. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/GetDisplayNameTests.cs | Converts non-parallelizable/parameterized tests to MSTest equivalents. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/DocumentationSignatureParserTests.cs | Converts parameterized tests to MSTest DynamicData. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/CodeOptimizationsSettingsTests.cs | Converts test attributes/usings to MSTest. |
| src/tools/illink/test/Mono.Linker.Tests/Tests/AnnotationStoreTest.cs | Converts to MSTest [TestClass]/[TestMethod]. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs | Replaces NUnit using with MSTest using in the test runner integration. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCompiler.cs | Replaces NUnit using with MSTest using. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseCollector.cs | Updates comments referring to test framework attributes/data sources. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs | Replaces NUnit using with MSTest using. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/MemberAssertionsCollector.cs | Changes member assertion data generation to MSTest data row types. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ILVerification/ILVerifier.cs | Replaces NUnit using with MSTest using. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ILVerification/ILChecker.cs | Replaces NUnit using with MSTest using. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ILCompiler.cs | Replaces NUnit using with MSTest using. |
| src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs | Replaces NUnit using with MSTest using. |
| src/tools/illink/test/Mono.Linker.Tests/TestCases/TestSuites.cs | Converts suite runners to MSTest DynamicData. |
| src/tools/illink/test/Mono.Linker.Tests/TestCases/TestDatabase.cs | Converts test case enumeration helpers from NUnit to MSTest data row patterns. |
| src/tools/illink/test/Mono.Linker.Tests/TestCases/IndividualTests.cs | Converts individual tests to MSTest. |
| src/tools/illink/test/Mono.Linker.Tests/Mono.Linker.Tests.csproj | Switches TestRunnerName from NUnit to MSTest. |
| src/tools/illink/test/Mono.Linker.Tests/AssemblyInfo.cs | Replaces NUnit assembly parallelization with MSTest [assembly: Parallelize]. |
Comments suppressed due to low confidence (3)
src/tools/illink/test/Mono.Linker.Tests/Tests/PreserveActionComparisonTests.cs:30
- This test class is switched to MSTest attributes, but the assertions still use NUnit's constraint model (e.g., Assert.That / Is.EqualTo). These APIs aren't available in MSTest and will fail to compile unless a compatibility layer is provided; replace with MSTest assertions (e.g., Assert.AreEqual / Assert.IsTrue, etc.).
public void VerifyBehaviorOfChoosePreserveActionWhichPreservesTheMost(TypePreserve left, TypePreserve right, TypePreserve expected)
{
Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(left, right)));
Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(right, left)));
src/tools/illink/test/Mono.Linker.Tests/TestCases/TestSuites.cs:61
- MSTest doesn't have Assert.Ignore(). If these tests need to be skipped at runtime, use an MSTest-supported mechanism (e.g., throw AssertInconclusiveException / call Assert.Inconclusive, or use an [Ignore] attribute with a condition handled by the runner).
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
Assert.Ignore("These tests are not valid when trimming .NET Framework");
src/tools/illink/test/Mono.Linker.Tests/Tests/DocumentationSignatureParserTests.cs:50
- Assert.NotNull is not an MSTest Assert API (MSTest uses Assert.IsNotNull). This will fail to compile after the NUnit->MSTest switch; update to the MSTest assertion method.
public static void CheckUniqueParsedString(IMemberDefinition member, string input)
{
var module = (member as TypeDefinition)?.Module ?? member.DeclaringType?.Module;
Assert.NotNull(module);
var parseResults = DocumentationSignatureParser.GetMembersForDocumentationSignature(input, module, new TestResolver());
Assert.AreEqual(1, parseResults.Count());
Assert.AreEqual(member, parseResults.First());
src/tools/illink/test/Mono.Linker.Tests/Tests/CodeOptimizationsSettingsTests.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCases/TestDatabase.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/DocumentationSignatureParserTests.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/TestFrameworkRulesAndConventions.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
1323c8f to
3ebf366
Compare
3ebf366 to
241fac1
Compare
241fac1 to
15242f0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated 23 comments.
Comments suppressed due to low confidence (1)
src/tools/illink/test/Mono.Linker.Tests/Tests/PreserveActionComparisonTests.cs:30
- This test still uses NUnit constraint assertions (
Assert.That(..., Is.EqualTo(...))), but the file now references MSTest.Assert.That/Iswon't compile under MSTest; replace these with MSTest asserts (e.g.,Assert.AreEqual(...)).
public void VerifyBehaviorOfChoosePreserveActionWhichPreservesTheMost(TypePreserve left, TypePreserve right, TypePreserve expected)
{
Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(left, right)));
Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(right, left)));
src/tools/illink/test/Mono.Linker.Tests/Tests/PreserveActionComparisonTests.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/ParseResponseFileLinesTests.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/TestFrameworkRulesAndConventions.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/MemberAssertionsCollector.cs
Show resolved
Hide resolved
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/TestChecker.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/CompilationExtensions.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/DependencyInjectionPattern.cs
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
15242f0 to
4fcf4a3
Compare
4fcf4a3 to
d2f71f7
Compare
dcbfb1a to
f61e904
Compare
src/tools/illink/test/Mono.Linker.Tests/Tests/ParseResponseFileLinesTests.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
f61e904 to
4027be0
Compare
This comment has been minimized.
This comment has been minimized.
4027be0 to
72de02f
Compare
src/tools/illink/test/Mono.Linker.Tests/Tests/TestFrameworkRulesAndConventions.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/TestFrameworkRulesAndConventions.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/DocumentationSignatureParserTests.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/DocumentationSignatureParserTests.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/MemberAssertionsCollector.cs
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/Tests/TestFrameworkRulesAndConventions.cs
Show resolved
Hide resolved
|
Note This review was generated by Copilot. 🤖 Copilot Code Review — PR #126412Holistic AssessmentMotivation: This PR migrates Approach: The migration is thorough and mechanical — attribute substitutions ( Summary: ✅ LGTM. The migration is comprehensive and correct. All NUnit assertion methods are properly mapped to their MSTest equivalents with correct argument ordering (verified against the MSTest source). Two minor style observations noted below, neither blocking. Detailed Findings✅ Assertion API Correctness — Verified against MSTest sourceAll assertion conversions were verified against the actual MSTest source code:
✅ Data Source Migration — Correct
✅ Attribute Migration — CompleteAll NUnit attributes properly mapped: 💡 Using Directive Ordering —
|
sbomer
left a comment
There was a problem hiding this comment.
This change looks ok to me, but I would prefer to migrate to xunit instead for consistency, did you consider that?
|
I considered that, but it's way easier to move to MSTest as the API surface is quite close to NUnit, while very different for xUnit and will require more efforts. |
jtschuster
left a comment
There was a problem hiding this comment.
LGTM if we just want to drop NUnit asap. Might be worth a shot to see if copilot could migrate to XUnit once this is in, though.
|
/ba-g failing jobs don't run this test suite, unrelated |
Related to dotnet/arcade#16428