Skip to content

feat: Migrate tests from xunit to TUnit#875

Merged
BenjaminMichaelis merged 8 commits intomainfrom
bmichaelis/tunit
Feb 26, 2026
Merged

feat: Migrate tests from xunit to TUnit#875
BenjaminMichaelis merged 8 commits intomainfrom
bmichaelis/tunit

Conversation

@BenjaminMichaelis
Copy link
Member

  • 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

Copilot AI review requested due to automatic review settings February 25, 2026 05:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 test to use Microsoft.Testing.Platform via global.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
@BenjaminMichaelis BenjaminMichaelis self-assigned this Feb 25, 2026
@BenjaminMichaelis BenjaminMichaelis merged commit 69735f3 into main Feb 26, 2026
7 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the bmichaelis/tunit branch February 26, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants