-
-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Description
The TUnit xUnit migration code fixer (diagnostic TUXU0001) is leaving merge conflict markers in the code during automatic migration, causing compilation errors.
Environment
- TUnit Version: 1.12.90
- .NET SDK: 10.0.100
- Original Testing Framework: xUnit 2.9.3
- Target Frameworks: net472, net8.0
- Language Version: C# 12.0
Reproduction Steps
- Create or clone a project with xUnit tests (tested with https://github.com/devlooped/moq - Moq.Tests project)
- Add TUnit package:
dotnet add package TUnit - Temporarily disable implicit usings in
.csproj:<TUnitImplicitUsings>false</TUnitImplicitUsings> <TUnitAssertionsImplicitUsings>false</TUnitAssertionsImplicitUsings>
- Run the code fixer:
dotnet format analyzers --severity info --diagnostics TUXU0001 --framework net8.0
Expected Behavior
The code fixer should automatically convert xUnit assertions to TUnit assertions without leaving merge conflict markers.
Actual Behavior
The code fixer leaves merge conflict markers in the code like:
<<<<<<< TODO: Unmerged change from project 'Moq.Tests(net8.0)', Before:
Assert.NotEqual(mock1.Object.GetHashCode(), mock2.Object.GetHashCode());
=======
Assert.NotEqual(mock2.Object.GetHashCode());
>>>>>>> After
await Assert.That(mock1.Object.GetHashCode()).IsEqualTo(mock1.Object.GetHashCode());Impact
- Compilation fails with CS8300 errors: "Merge conflict marker encountered"
- Additional cascading syntax errors due to incomplete code
- Affects 2 files in the test project with 23 total merge conflict markers
- Files affected:
MockFixture.cs(4 markers),Regressions/IssueReportsFixture.cs(19 markers)
Assertion Patterns Affected
The issue appears when converting:
Assert.Equal(expected, actual)with two argumentsAssert.NotEqual(expected, actual)with two arguments- Potentially other multi-argument assertions
Workaround
Manual removal of merge conflict markers and correction of the generated assertions is required.
Additional Context
According to the migration guide at https://tunit.dev/docs/migration/xunit, the code fixer should handle "80-90% of typical test suites automatically." This bug significantly impacts the automated migration experience.
The project being migrated is the Moq library test suite, which contains extensive xUnit tests, making it a good real-world test case for the migration tooling.