-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Migrate Xaml.UnitTests from NUnit to xUnit #33012
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
Conversation
Complete migration of src/Controls/tests/Xaml.UnitTests from NUnit to xUnit testing framework.
2c971b9 to
e69b5a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the Controls.Xaml.UnitTests project from NUnit to xUnit testing framework as part of issue #32247. The migration replaces NUnit attributes and assertions with xUnit equivalents while maintaining test functionality. All 1782 tests pass successfully.
Key changes:
- Replaced NUnit test attributes with xUnit equivalents (
[TestFixture]→[Collection],[Test]→[Fact]/[Theory]) - Converted parameterized tests to use
[Theory]with[XamlInflatorData]or[InlineData] - Updated assertions from NUnit syntax to xUnit (
Assert.That()→Assert.Equal(), etc.) - Replaced
[SetUp]/[TearDown]with constructor/IDisposable.Dispose() - Added collection attributes to organize tests and disable parallelization
Reviewed changes
Copilot reviewed 300 out of 412 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Maui25406.xaml.cs | Migrated XamlC compilation test to xUnit with IDisposable pattern |
| Maui25309.xaml.cs | Converted generic converter test using XamlInflatorData |
| Maui25172.xaml.cs | Updated generic base class compilation test |
| Maui25141.xaml.cs | Migrated data trigger and multibinding test |
| Maui24900.xaml.cs | Converted OnPlatform test with Record.Exception pattern |
| Maui24849.xaml.cs | Updated VSG (Visual State Group) test with xUnit assertions |
| Maui24500.xaml.cs | Migrated OnIdiom binding test |
| Maui24472.xaml.cs | Converted x:Array test |
| Maui24384.xaml.cs | Updated immutable collection test |
| Maui2418.rtsg.xaml.cs | Migrated source info test with InlineData for specific inflators |
| Maui23989.xaml.cs | Converted ItemDisplayBinding test with XamlExceptionAssert |
| Maui23711.xaml.cs | Updated binding compilation test |
| Maui23347.xaml.cs | Migrated FontImageSource test |
| Maui23201.xaml.cs | Converted ToolBarItem AppTheme binding test |
| Maui2304Closed.xaml.cs | Updated XamlC test |
| Maui22877.xaml.cs | Migrated OnBinding release test |
| Maui22714.rt.xaml.cs | Converted resource dictionary test with inline data combinations |
| Maui22536.xaml.cs | Updated non-compiled resource dictionary test |
| Maui22105.xaml.cs | Migrated default value test |
| Maui22036.xaml.cs | Converted async style trigger leak test |
| (Additional files) | Similar xUnit migration patterns applied across 100+ test files |
| [Test] | ||
| public void VerifyCorrectTypesUsed([Values] XamlInflator inflator) | ||
| [Theory] | ||
| [InlineData(XamlInflator.Runtime)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this use XamlInflatorData ?
rmarinho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did n t saw nothing bad, maybe just some exceptions where we check the lines, I wonder if we can use XamlExceptionAssert.ThrowsBuildException , but looks good to merge
| else if (inflator == XamlInflator.Runtime) | ||
| Assert.Throws(new XamlParseExceptionConstraint(9, 6), () => new Bz43694(inflator)); | ||
| { | ||
| var ex = Assert.ThrowsAny<Exception>(() => new Bz43694(inflator)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a way to check the line is correct here?
| Assert.Single(result.Diagnostics); | ||
| } | ||
| else | ||
| Assert.Ignore($"Test not supported for {inflator}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We lost this one , but I think is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is fine
| } | ||
| """) | ||
| .RunMauiSourceGenerator(typeof(Gh4751)); | ||
| //FIXME check the diagnostic code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fix it now?
| } | ||
| """) | ||
| .RunMauiSourceGenerator(typeof(Gh5378_1)); | ||
| //FIXME check diagnostic code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we fix it ?
| """) | ||
| .RunMauiSourceGenerator(typeof(Gh7187)); | ||
| //FIXME check diagnostic code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check the code now ?
| @@ -218,7 +219,6 @@ public void Issue1493(string culture) | |||
| cmp:RelativeLayout.WidthConstraint=""{cmp:ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6}""/>"; | |||
| View view = new View(); | |||
| view.LoadFromXaml(xaml); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DO we need to use the Record.
- Bz43694, Bz44216, Issue2450: Use XamlExceptionAssert to check exception line/position and message content - Maui17222: Replace IDisposable with try/finally for cleanup
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
This PR migrates the
Controls.Xaml.UnitTestsproject from NUnit to xUnit, as part of the effort tracked in #32247.Changes
Test Framework Migration
[TestFixture]with xUnit[Collection]attributes[Test]to[Theory]with[MemberData]for parameterized tests[Values]attribute pattern withXamlInflatorTestDatamember data providerAssert.That()/Assert.AreEqual()to xUnitAssert.Equal()/Assert.NotNull()etc.[SetUp]/[TearDown]with xUnit constructor /IDisposable.Dispose()patternAssert.Throws<T>/Assert.DoesNotThrowwith xUnit equivalentsTest Organization
[Collection("Xaml Inflation")][Collection("Issue")]DisableParallelization = trueto maintain test isolationInfrastructure
XamlInflatorTestDataclass providingIEnumerable<object[]>for inflator variationsTest Results
All 1782 tests passing (same count as main branch).
Fixes #32247