Migrate unit tests from xUnit to TUnit#830
Conversation
WalkthroughMigrate test projects from xUnit to TUnit across most test files, convert parameterized attributes to TUnit equivalents, adjust a few test signatures (notably SerializerTests), add global.json and MSBuild testing props, and update CI test/coverage invocations and test project dependencies. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧠 Learnings (9)📓 Common learnings📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
📚 Learning: 2025-10-20T20:29:54.111ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request migrates all unit tests from xUnit to the TUnit testing framework, successfully converting 852 tests. The migration involves replacing test attributes, updating project dependencies, and modernizing test patterns.
Key changes:
- Replaced xUnit package references with TUnit in test projects
- Converted all
[Fact]attributes to[Test]and[Theory]/[InlineData]to[Test]/[Arguments] - Removed AutoFixture dependency and refactored tests to use explicit test data
- Updated project configurations to support TUnit's execution model
Reviewed changes
Copilot reviewed 80 out of 80 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Refitter.Tests.csproj | Replaced xUnit packages with TUnit, added required project properties |
| Refitter.SourceGenerator.Tests.csproj | Updated to TUnit, configured for test execution |
| SwaggerPetstoreTests.cs | Migrated 223 test cases from xUnit attributes to TUnit |
| SerializerTests.cs | Removed AutoFixture dependency, refactored to use explicit test data |
| CustomCSharpGeneratorSettingsTests.cs | Removed AutoFixture, migrated to TUnit with explicit parameters |
| XmlDocumentationGeneratorTests.cs | Converted all Fact attributes to Test |
| SwaggerPetstoreApizrTests.cs | Migrated 156 test cases to TUnit |
| Multiple example test files | Converted test attributes consistently across all test scenarios |
| Source generator test files | Updated to TUnit attributes and patterns |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
src/Refitter.Tests/Examples/OperationIdWithInvalidFirstCharTests.cs (1)
41-41: Consider fixing typos in method name.The method name contains "Ivalid" (should be "Invalid") and "Methode" (should be "Method"). While this doesn't affect functionality, correcting it would improve readability.
Apply this diff to fix the typos:
- public async Task Adds_Underscore_At_Beginning_With_Ivalid_Methode_Name() + public async Task Adds_Underscore_At_Beginning_With_Invalid_Method_Name()src/Refitter.Tests/DependencyInjectionGeneratorWithPollyTests.cs (1)
3-3: TUnit migration is fine; consider avoiding shared mutablesettingsThe switch to
using TUnit.Core;and[Test]on all DI/Polly tests is consistent, and the assertion logic is unchanged. However, several tests mutatesettings.DependencyInjectionSettings!(e.g.,TransientErrorHandlerandBaseUrl), which can couple tests together if the framework ever reuses the same test-class instance or changes parallelization behavior. It would be safer to construct a freshRefitGeneratorSettingsper test (or clone/resetsettings.DependencyInjectionSettings) to make tests independent; also, the"Backoff.DecorrelatedJitterBackoffV2"NotContainassertion is duplicated and could be trimmed.Please confirm TUnit uses per-test-class-instance semantics similar to xUnit here, or consider refactoring to per-test settings to avoid any potential flakiness under parallel runs.
Also applies to: 25-103
src/Refitter.Tests/DependencyInjectionGeneratorWithMicrosoftHttpResilienceTests.cs (1)
9-21: Shared mutablesettingsinstance may be fragile under parallel executionSeveral tests mutate the shared
settings.DependencyInjectionSettings(e.g., changingTransientErrorHandlerandBaseUrl), which can introduce hidden coupling or flakiness if the runner ever executes these tests in parallel or in an unexpected order. Consider creating a freshRefitGeneratorSettingsper test (or cloning the base configuration) for the tests that modify it to make them independent.Also applies to: 67-83, 85-99
src/Refitter.Tests/ApizrGeneratorWithPollyTests.cs (1)
9-33: Avoid mutating the shared_extendedSettingsacross tests
_extendedSettings.DependencyInjectionSettingsis modified in multiple tests (e.g., togglingTransientErrorHandlerandBaseUrl), which couples tests together and can introduce flakes if execution order or parallelism changes. It would be more robust to construct a freshRefitGeneratorSettings(or clone_extendedSettings) inside the tests that need to modify it so each test is independent.Also applies to: 94-110, 112-125
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/build.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to src/Refitter.Tests/Examples/**/*.cs : Add unit tests for new CLI options in src/Refitter.Tests/Examples/ following the established test structure
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to src/Refitter.Tests/Examples/**/*.cs : New unit tests must follow the pattern used in Refitter.Tests.Examples (Arrange/Act/Assert style with GenerateCode(), content assertions, and build verification)
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Multi-targeting: test .NET 8.0 and 9.0 when making framework-specific changes
📚 Learning: 2025-10-20T20:29:54.111Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to .github/workflows/*.yml : Ensure CI requirements are met: builds pass on Windows, code formatted, tests pass (except allowed network failures), code coverage and workflows run
Applied to files:
.github/workflows/build.yml
📚 Learning: 2025-10-20T20:29:54.111Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to src/Refitter.sln : Use the main solution file src/Refitter.sln for restore, build, test, and formatting operations
Applied to files:
.github/workflows/build.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: 👌 Verify build
- GitHub Check: 👌 Verify build
- GitHub Check: Analyze (csharp)
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/codecov.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to src/Refitter.Tests/Examples/**/*.cs : Add unit tests for new CLI options in src/Refitter.Tests/Examples/ following the established test structure
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to src/Refitter.Tests/Examples/**/*.cs : New unit tests must follow the pattern used in Refitter.Tests.Examples (Arrange/Act/Assert style with GenerateCode(), content assertions, and build verification)
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Multi-targeting: test .NET 8.0 and 9.0 when making framework-specific changes
📚 Learning: 2025-10-20T20:29:54.111Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to **/*.cs : Run dotnet format and ensure no formatting changes before committing
Applied to files:
.github/workflows/codecov.yml
📚 Learning: 2025-10-20T20:29:54.111Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to src/Refitter.Tests/Examples/**/*.cs : Add unit tests for new CLI options in src/Refitter.Tests/Examples/ following the established test structure
Applied to files:
.github/workflows/codecov.yml
📚 Learning: 2025-10-20T20:29:54.111Z
Learnt from: CR
Repo: christianhelle/refitter PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-20T20:29:54.111Z
Learning: Applies to .github/workflows/*.yml : Ensure CI requirements are met: builds pass on Windows, code formatted, tests pass (except allowed network failures), code coverage and workflows run
Applied to files:
.github/workflows/codecov.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: 👌 Verify build
- GitHub Check: 👌 Verify build
- GitHub Check: Analyze (csharp)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #830 +/- ##
==========================================
- Coverage 95.14% 92.72% -2.43%
==========================================
Files 23 23
Lines 1938 1938
Branches 319 0 -319
==========================================
- Hits 1844 1797 -47
Misses 48 48
- Partials 46 93 +47
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Updated [refitter](https://github.com/christianhelle/refitter) from 1.7.0 to 1.7.1. <details> <summary>Release notes</summary> _Sourced from [refitter's releases](https://github.com/christianhelle/refitter/releases)._ ## 1.7.1 ### Implemented enhancements - Improved handling of optional parameters [\#448](christianhelle/refitter#448) by @christianhelle - Allow omitting certain operation headers \#840 [\#841](christianhelle/refitter#841) by @kmc059000 - Migrate unit tests from xUnit to TUnit [\#830](christianhelle/refitter#830) by @christianhelle - Refit v9.0.2 [\#829](christianhelle/refitter#829) - Add .NET 10 support [\#822](christianhelle/refitter#822) ([christianhelle](https://github.com/christianhelle)) - Fix missing XML doc for CancellationToken [\#819](christianhelle/refitter#819) by @christianhelle - Fix incorrect casing on multi-part form data parameters [\#806](christianhelle/refitter#806) by @christianhelle - Optional parameters with default values [\#803](christianhelle/refitter#803) by @christianhelle - Asana API specs strange naming [\#364](christianhelle/refitter#364) by @christianhelle ### Fixed bugs - Using cancellation tokens with xml doc comments plus TreatWarningsAsErrors and documentation file [\#817](christianhelle/refitter#817) - Multipart form data parameters wrong casing [\#805](christianhelle/refitter#805) - Use of non generic `JsonStringEnumConverter` prohibits usage of Json-SourceGenerationContext [\#778](christianhelle/refitter#778) - SourceGenerator 1.5 and newer causes build error with Visual Studio 2022 [\#627](christianhelle/refitter#627) - Fix string escaping, null safety, and numeric literals in optional parameter default values [\#804](christianhelle/refitter#804) - Fix typo in class name and Spectre.Console markup escaping issue [\#828](christianhelle/refitter#828) ### Merged pull requests - docs: add kmc059000 as a contributor for ideas, and code [\#842](christianhelle/refitter#842) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - Bump actions/upload-artifact from 5 to 6 [\#838](christianhelle/refitter#838) ([dependabot[bot]](https://github.com/apps/dependabot)) - Update dependency TUnit to 1.5.37 [\#836](christianhelle/refitter#836) ([renovate[bot]](https://github.com/apps/renovate)) - Update dotnet monorepo [\#834](christianhelle/refitter#834) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency TUnit to 1.5.6 [\#833](christianhelle/refitter#833) ([renovate[bot]](https://github.com/apps/renovate)) - Update dependency TUnit to 1.5.0 [\#832](christianhelle/refitter#832) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency spectre.console.cli to 0.53.1 [\#827](christianhelle/refitter#827) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency polly to 8.6.5 [\#826](christianhelle/refitter#826) ([renovate[bot]](https://github.com/apps/renovate)) - Bump actions/checkout from 5 to 6 [\#825](christianhelle/refitter#825) ([dependabot[bot]](https://github.com/apps/dependabot)) - chore\(deps\): update nswag monorepo to 14.6.3 [\#824](christianhelle/refitter#824) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency microsoft.build.utilities.core to v18 [\#821](christianhelle/refitter#821) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency swashbuckle.aspnetcore to 10.0.1 [\#820](christianhelle/refitter#820) ([renovate[bot]](https://github.com/apps/renovate)) - docs: add karoberts as a contributor for bug [\#818](christianhelle/refitter#818) ([allcontributors[bot]](https://github.com/apps/allcontributors)) - chore\(deps\): update dependency swashbuckle.aspnetcore to v10 [\#816](christianhelle/refitter#816) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency microsoft.extensions.http.resilience to v10 [\#815](christianhelle/refitter#815) ([renovate[bot]](https://github.com/apps/renovate)) - Update Spectre.Console.Cli to 0.53.0 [\#814](christianhelle/refitter#814) ([Copilot](https://github.com/apps/copilot-swe-agent)) - chore\(deps\): update dotnet monorepo to v10 \(major\) [\#813](christianhelle/refitter#813) ([renovate[bot]](https://github.com/apps/renovate)) - chore\(deps\): update dependency microsoft.net.test.sdk to 18.0.1 [\#808](christianhelle/refitter#808) ([renovate[bot]](https://github.com/apps/renovate)) - docs: add mhartmair-cubido as a contributor for bug [\#807](christianhelle/refitter#807) ([allcontributors[bot]](https://github.com/apps/allcontributors)) ### New Contributors * @kmc059000 made their first contribution in christianhelle/refitter#841 Full Changelog: christianhelle/refitter@1.7.0...1.7.1 Commits viewable in [compare view](christianhelle/refitter@1.7.0...1.7.1). </details> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>



Migrates all unit tests from xUnit to TUnit testing framework
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.