Skip to content

NUnit Migration: using NUnit.Framework; statements not removed #4337

@thomhurst

Description

@thomhurst

Description

When running the TUnit NUnit migration code fixer using dotnet format analyzers --severity info --diagnostics TUNU0001, the using NUnit.Framework; statements are not removed from the migrated files, even though TUnit usings are added.

Steps to Reproduce

  1. Create a project with NUnit tests
  2. Add TUnit packages
  3. Run dotnet format analyzers --severity info --diagnostics TUNU0001
  4. Build the project

Expected Behavior

The using NUnit.Framework; statements should be removed after migration since NUnit is no longer used.

Actual Behavior

The NUnit using statements remain, causing build errors when NUnit packages are removed:

error CS0246: The type or namespace name 'NUnit' could not be found

Example

Before migration:

using NUnit.Framework;

[TestFixture]
public class MyTests
{
    [Test]
    public void MyTest()
    {
        Assert.IsNotNull(someValue);
    }
}

After migration (current):

using System.Threading.Tasks;
using TUnit.Core;
using TUnit.Assertions;
using static TUnit.Assertions.Assert;
using TUnit.Assertions.Extensions;
// ... license header ...

using NUnit.Framework;  // <-- Still present

public class MyTests
{
    [Test]
    public async Task MyTest()
    {
        await Assert.That(someValue).IsNotNull();
    }
}

Expected after migration:

using System.Threading.Tasks;
using TUnit.Core;
using TUnit.Assertions;
using static TUnit.Assertions.Assert;
using TUnit.Assertions.Extensions;
// ... license header ...

// No NUnit using statement

public class MyTests
{
    [Test]
    public async Task MyTest()
    {
        await Assert.That(someValue).IsNotNull();
    }
}

Environment

  • TUnit version: 1.9.91
  • .NET version: .NET 8.0
  • OS: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions