-
-
Notifications
You must be signed in to change notification settings - Fork 110
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
When running the TUXU0001 code fixer for xUnit migration, the code fixer adds TUnit usings but does not consistently remove the using Xunit; statements, leaving them in some files.
Steps to Reproduce
- Create a test file with xUnit:
using System.Threading.Tasks;
namespace Moq.Tests.Async
{
using System.Threading.Tasks;
using Moq.Async;
using Xunit;
public class AwaitableFixture
{
[Fact]
public void TryGetResultRecursive_is_recursive()
{
const int expectedResult = 42;
var obj = Task.FromResult(Task.FromResult(expectedResult));
var result = Awaitable.TryGetResultRecursive(obj);
Assert.Equal(expectedResult, result);
}
}
}- Install TUnit package alongside xUnit
- Run the code fixer:
dotnet format analyzers --severity warn --diagnostics TUXU0001
Expected Behavior
The using Xunit; statement should be removed and replaced with appropriate TUnit usings:
using System.Threading.Tasks;
namespace Moq.Tests.Async
{
using System.Threading.Tasks;
using Moq.Async;
// using Xunit; should be removed
public class AwaitableFixture
{
[Test]
public async Task TryGetResultRecursive_is_recursive()
{
// ...
}
}
}Actual Behavior
The code fixer converts the test attributes and assertions but leaves the using Xunit; statement in place:
using System.Threading.Tasks;
namespace Moq.Tests.Async
{
using System.Threading.Tasks;
using Moq.Async;
using Xunit; // <-- Still present!
public class AwaitableFixture
{
[Test] // Converted
public async Task TryGetResultRecursive_is_recursive()
{
// Converted assertions
}
}
}This causes:
CS0246: The type or namespace name 'Xunit' could not be foundafter removing xUnit package
Environment
- TUnit Version: 1.11.64
- .NET SDK: 10.0.102
- OS: Windows
Observation
This may be related to the using statement being inside a namespace block rather than at the file level.
Tests to Add
Please add tests for:
using Xunit;at file levelusing Xunit;inside namespace block- Multiple using statements on same line
- Using alias like
using X = Xunit;
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working