feat: Migrate tests from xunit to TUnit#875
Merged
BenjaminMichaelis merged 8 commits intomainfrom Feb 26, 2026
Merged
Conversation
Member
BenjaminMichaelis
commented
Feb 25, 2026
- Replace xunit + coverlet with TUnit test framework
- Update test project files to use TUnit package references
- Add Microsoft.Testing.Platform runner config to global.json
- Update CI test command for TUnit MTP compatibility
- Convert all test classes and assertions to TUnit syntax
- Add [NotInParallel] to tests using shared SQLite state
- Use IsEquivalentTo for collection comparisons
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the solution’s test projects from xUnit/vstest to TUnit running on Microsoft.Testing.Platform (MTP), updating CI and test code to the new attribute/assertion model.
Changes:
- Configure
dotnet testto use Microsoft.Testing.Platform viaglobal.json, and update PR CI to emit TRX under MTP. - Replace xUnit + coverlet + vstest package references with TUnit in both test projects.
- Convert test attributes and assertions from xUnit syntax to TUnit syntax (including parallelization controls/data sources).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| global.json | Selects Microsoft.Testing.Platform as the test runner for dotnet test. |
| EssentialCSharp.Web.Tests/Usings.cs | Removes global xUnit using. |
| EssentialCSharp.Web.Tests/StringExtensionsTests.cs | Converts xUnit theory/assertions to TUnit [Test]/[Arguments] + Assert.That. |
| EssentialCSharp.Web.Tests/SitemapXmlHelpersTests.cs | Converts fixture pattern to TUnit data source and adds [NotInParallel]. |
| EssentialCSharp.Web.Tests/SiteMappingTests.cs | Converts xUnit facts/theories to TUnit tests and equivalents. |
| EssentialCSharp.Web.Tests/RouteConfigurationServiceTests.cs | Converts xUnit fixture usage to TUnit class data source. |
| EssentialCSharp.Web.Tests/ListingSourceCodeServiceTests.cs | Converts assertions to TUnit and adjusts collection comparisons. |
| EssentialCSharp.Web.Tests/ListingSourceCodeControllerTests.cs | Converts integration tests to TUnit assertions. |
| EssentialCSharp.Web.Tests/Integration/CaptchaTests.cs | Converts xUnit fixture test to TUnit class data source and assertions. |
| EssentialCSharp.Web.Tests/FunctionalTests.cs | Converts xUnit theories/facts to TUnit argument-based tests. |
| EssentialCSharp.Web.Tests/EssentialCSharp.Web.Tests.csproj | Swaps xUnit/vstest/coverlet references for TUnit. |
| EssentialCSharp.Chat.Tests/MarkdownChunkingServiceTests.cs | Converts xUnit tests to TUnit assertions. |
| EssentialCSharp.Chat.Tests/EssentialCSharp.Chat.Tests.csproj | Swaps xUnit/vstest/coverlet references for TUnit. |
| Directory.Packages.props | Central package updates: remove xUnit/vstest/coverlet versions; add TUnit version. |
| .github/workflows/PR-Build-And-Test.yml | Updates dotnet test invocation to use MTP TRX reporting arguments. |
- Replace xunit + coverlet with TUnit test framework - Update test project files to use TUnit package references - Add Microsoft.Testing.Platform runner config to global.json - Update CI test command for TUnit MTP compatibility - Convert all test classes and assertions to TUnit syntax - Add [NotInParallel] to tests using shared SQLite state - Use IsEquivalentTo for collection comparisons
- Use ThrowsNothing() instead of bare method call in DoesNotThrow test - Use WithMessageContaining() chained on Throws<>() instead of capturing exception variable and checking .Message with Contains() - For multiple message checks, use .And.HasMessageContaining()
- Fix 8 NRE occurrences in MarkdownChunkingServiceTests.cs: replace
FirstOrDefault + .Header access with Assert.That(sections).Contains(predicate)
- Remove redundant string.Join assertion (line 208) in MarkdownChunkingServiceTests.cs
- Remove #pragma CA1707 disable/restore from MarkdownChunkingServiceTests.cs
- Add CA1707 suppression to .editorconfig for test projects (replaces csproj NoWarn)
- Remove <NoWarn>CA1707</NoWarn> from Web.Tests.csproj
- Update TUnit 1.17.11 -> 1.17.20 in Directory.Packages.props
- Add [NotInParallel('FunctionalTests')] to fix parallel SQLite transaction conflict:
XUnit ran tests sequentially within a class; TUnit runs in parallel, causing
multiple EF Core operations to call BeginTransaction on the same SQLite
connection simultaneously
- Add --coverage to CI dotnet test command (replaces removed coverlet.collector)
- Add [Timeout(30_000)] with CancellationToken to CaptchaService_Verify_Success
- Standardize StringComparison.OrdinalIgnoreCase in SitemapXmlHelpersTests URL predicates
- Wrap foreach assertions with Assert.Multiple() in ListingSourceCode tests
- Add IAsyncInitializer to WebApplicationFactory for eager server initialization
763c2b0 to
798fa68
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.