Loading...
Loading...
Migrates .NET test projects from xUnit.net v2 to xUnit.net v3. USE FOR: upgrading xunit to xunit.v3. DO NOT USE FOR: migrating between test frameworks (MSTest/NUnit to xUnit.net), migrating from VSTest to Microsoft.Testing.Platform (use migrate-vstest-to-mtp). For xUnit v3 MTP filter syntax (--filter-class, --filter-trait, --filter-query), also load migrate-vstest-to-mtp.
npx skill4agent add dotnet/skills migrate-xunit-to-xunit-v3xunit.v3.*xunitxunit.v3migrate-vstest-to-mtpxunit.v3| Input | Required | Description |
|---|---|---|
| Test project or solution | Yes | The .NET project or solution containing xUnit.net v2 test projects |
Commit strategy: Commit after each major step so the migration is reviewable and bisectable. Separate project file changes from code changes.
Prioritization: Steps 1-5 are required for every migration. Steps 6-12 are conditional — only apply the ones relevant to the project's code patterns. Skip steps that don't apply.
xunitxunit.abstractionsxunit.assertxunit.corexunit.extensibility.corexunit.extensibility.executionxunit.runner.visualstudioDirectory.Build.propsDirectory.Build.targetsDirectory.Packages.propsPackageReferencePackageVersionxunitxunit.v3xunit.abstractionsxunit.assertxunit.v3.assertxunit.corexunit.v3.corexunit.extensibility.corexunit.extensibility.executionxunit.v3.extensibility.corexunit.v3.*xunit.runner.visualstudioOutputTypeExeOutputTypeExe<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>Directory.Build.props<OutputType>Exe</OutputType>Directory.Build.targets*.Tests.csprojDirectory.Build.props<OutputType Condition="$(MSBuildProjectName.EndsWith('.Tests'))">Exe</OutputType><OutputType>Exe</OutputType>YTest.MTP.XUnit2YTest.MTP.XUnit2YTest.MTP.XUnit2<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>Directory.Build.propsPropertyGroupYTest.MTP.XUnit2<IsTestingPlatformApplication>false</IsTestingPlatformApplication>Directory.Build.propsPropertyGroupDirectory.Build.propsXunit.Abstractionsusing Xunit.Abstractions;async voidasync voidasync voidasync Task[Fact][Theory]System.TypeCollectionBehaviorAttributeTestCaseOrdererAttributeTestCollectionOrdererAttributeTestFrameworkAttribute[assembly: CollectionBehavior("MyNamespace.MyCollectionFactory", "MyAssembly")][assembly: CollectionBehavior(typeof(MyNamespace.MyCollectionFactory))]FactAttributeTheoryAttributeinternal sealed class MyFactAttribute : FactAttribute
{
public MyFactAttribute()
{
}
}internal sealed class MyFactAttribute : FactAttribute
{
public MyFactAttribute(
[CallerFilePath] string? sourceFilePath = null,
[CallerLineNumber] int sourceLineNumber = -1
) : base(sourceFilePath, sourceLineNumber)
{
}
}BeforeAfterTestAttributeBeforeAfter public override void Before(MethodInfo methodUnderTest)
{
// Possibly some custom logic here
base.Before(methodUnderTest);
// Possibly some custom logic here
}
public override void After(MethodInfo methodUnderTest)
{
// Possibly some custom logic here
base.After(methodUnderTest);
// Possibly some custom logic here
} public override void Before(MethodInfo methodUnderTest, IXunitTest test)
{
// Possibly some custom logic here
base.Before(methodUnderTest, test);
// Possibly some custom logic here
}
public override void After(MethodInfo methodUnderTest, IXunitTest test)
{
// Possibly some custom logic here
base.After(methodUnderTest, test);
// Possibly some custom logic here
}TestContext.Current.CancellationTokenCancellationTokenXunit.SkippableFactXunit.SkippableFactSkippableFactFactSkippableTheoryTheorySkip.IfAssert.SkipWhenSkip.IfNotAssert.SkipUnlessXunit.CombinatorialXunit.StaFactdotnet test