migrate-xunit-to-xunit-v3
Skill1k starsChanged 6 months agoMITView on GitHub
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.
1 other project uses a version of this, 1 of them edited.
Trending
Quiet since September.about the whole repository
Most recently taken up by
- Sorcha-Platform/Sorchaedited, first seen Jan 24, 2026
Who's talking about microsoft/testfx
- dotnet/sdk“[Proposal]: Add Microsoft.NET.Sdk.Testing”GitHub · Jun 7, 2025 · 10 reactions
- dependabot/dependabot-core“Dependabot job fails due to attempt to update packages referenced via an MSBuild SDK”GitHub · Feb 4, 2025 · 9 reactions
- xunit/visualstudio.xunit“Microsoft Testing Platform for xUnit”GitHub · Feb 22, 2024 · 6 reactions
- microsoft/testfx-docs“DataTestMethod vs TestMethod”GitHub · Dec 3, 2018 · 6 reactions
- nunit/nunit3-vs-adapter“Microsoft Testing Platform for NUnit”GitHub · Feb 19, 2024 · 5 reactions
The biggest 5 of 17 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 17
Talked about on GitHub (17 times).
On GitHub · 17
- Jun 7, 2025[Proposal]: Add Microsoft.NET.Sdk.Testing — dotnet/sdksays it tested it10 reactions · 15 comments
- Feb 4, 2025Dependabot job fails due to attempt to update packages referenced via an MSBuild SDK — dependabot/dependabot-core9 reactions · 13 comments
- Feb 22, 2024Microsoft Testing Platform for xUnit — xunit/visualstudio.xunitsays it tested it6 reactions · 19 comments
- Dec 3, 2018DataTestMethod vs TestMethod — microsoft/testfx-docs6 reactions · 4 comments
- Feb 19, 2024Microsoft Testing Platform for NUnit — nunit/nunit3-vs-adaptersays it tested it5 reactions · 1 comment
12 more on GitHub
- Dec 19, 2023Arcade should opt into `BuildWithNetFrameworkHostedCompiler` by default — dotnet/arcade5 reactions · 18 comments
- Nov 24, 2025Native support for Microsoft.Testing.Platform? — danielpalme/ReportGeneratorsays it tested it4 reactions · 3 comments
- Oct 31, 2025Selecting test runner without global.json — dotnet/sdk3 reactions · 2 comments
- Jul 15, 2025[Analyzer Proposal]: Don't use `stringBuilder.Append(new string(c, repeatCount))` — dotnet/runtime3 reactions · 3 comments
- Jul 13, 2025Allow `dotnet test --list-tests json` — dotnet/sdk3 reactions · 7 comments
- Jul 9, 2025Improve output of `dotnet test` with MTP — dotnet/sdk3 reactions · 6 comments
- Jan 30, 2024Support for the new test runner — nunit/nunit3 reactions · 3 comments
- Oct 17, 2017[ExcludeFromCodeCoverageAttribute] should be applicable to assemblies — dotnet/runtime3 reactions · 12 comments
- Sep 2, 2026chore(deps): update mstest to 4.4.0 — thomhurst/TUnit2 reactions · 3 comments
- Dec 17, 2025[MTP] Cannot switch off terminal logger when building during dotnet test — dotnet/sdk2 reactions
- May 20, 2025Add `-vs` and `-vscode` to build scripts — dotnet/arcade2 reactions · 8 comments
- Jan 16, 2024An Allure adapter for MSTest — allure-framework/allure-csharp2 reactions · 2 comments
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- Sorcha-Platform/Sorcha★ 265% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository48 other files it gives its agents.
- AGENTS.mdAGENTS.md
- eng/common/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- assertion-qualitySkill
- binlog-failure-analysisSkill
- binlog-generationSkill
- build-parallelismSkill
- build-perf-baselineSkill
- build-perf-diagnosticsSkill
- check-bin-obj-clashSkill
- code-testing-agentSkill
- code-testing-extensionsSkill
- coverage-analysisSkill
- crap-scoreSkill
- detect-static-dependenciesSkill
- directory-build-organizationSkill
- dotnet-test-frameworksSkill
- eval-performanceSkill
- extension-pointsSkill
- filter-syntaxSkill
- generate-testability-wrappersSkill
- grade-testsSkill
- including-generated-filesSkill
- incremental-buildSkill
- item-managementSkill
- migrate-mstest-v1v2-to-v3Skill
- migrate-mstest-v3-to-v4Skill
- migrate-static-to-wrapperSkill
- migrate-vstest-to-mtpSkill
- migrate-xunit-to-mstestSkill
- msbuild-antipatternsSkill
- msbuild-modernizationSkill
- msbuild-serverSkill
- mtp-hot-reloadSkill
- platform-detectionSkill
- property-patternsSkill
- resolve-project-referencesSkill
- run-testsSkill
- target-authoringSkill
- test-analysis-extensionsSkill
- test-anti-patternsSkill
- test-gap-analysisSkill
- test-smell-detectionSkill
- test-taggingSkill
- writing-mstest-testsSkill
- agentic-workflowsSkill
- code-reviewSkill
- post-release-activitiesSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 1 is distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 43
Search for test projects referencing xUnit.net v2 packages:
- Very specific: line 53
Make sure to check the package references in project files, MSBuild props and targets files, like Directory.Build.props, …
- Very specific: line 59
Update any PackageReference or PackageVersion items for the new package names, based on the following mapping:
- Very specific: line 67
Update all xunit.v3.* packages to the latest correct version available on NuGet.
- Very specific: line 81
If all test projects share (or can share) a common Directory.Build.props, add the <OutputType>Exe</OutputType> property there.
- Very specific: line 82
If all test projects share a name pattern (e.g., *.Tests.csproj), add a conditional property group in Directory.Build.props that applies …
- Very specific: line 89
If the project had a reference to YTest.MTP.XUnit2:
- Very specific: line 90
Remove the reference to YTest.MTP.XUnit2 completely.
- Very specific: line 91
Add <UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner> to Directory.Build.props under an unconditional …
- Very specific: line 92
If the project did NOT reference YTest.MTP.XUnit2 (the common case):
- Very specific: line 93
Add <IsTestingPlatformApplication>false</IsTestingPlatformApplication> to Directory.Build.props under an unconditional PropertyGroup.
- Very specific: line 185
If there are any package references to Xunit.SkippableFact, remove all these package references entirely.
- Very specific: line 189
Update any SkippableFact attribute to the regular Fact attribute.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
xunit.v3 Migration
Migrate .NET test projects from xUnit.net v2 to xUnit.net v3. The outcome is a solution where all test projects reference xunit.v3.* packages, compiles cleanly, and all tests pass with the same results as before migration.
When to Use
- Upgrading test projects from
xunit(v2) packages toxunit.v3 - Resolving compilation errors after updating xunit package references to v3
When Not to Use
- Migrating between test frameworks (e.g., MSTest or NUnit to xUnit.net) — different effort entirely
- Migrating from VSTest to Microsoft.Testing.Platform — use
migrate-vstest-to-mtp - The projects already reference
xunit.v3— migration is done
Inputs
| Input | Required | Description |
| Test project or solution | Yes | The .NET project or solution containing xUnit.net v2 test projects |
Workflow
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.
Step 1: Identify xUnit.net projects and verify compatibility
Search for test projects referencing xUnit.net v2 packages:
xunitxunit.abstractionsxunit.assertxunit.corexunit.extensibility.corexunit.extensibility.executionxunit.runner.visualstudio
Make sure to check the package references in project files, MSBuild props and targets files, like Directory.Build.props, Directory.Build.targets, and Directory.Packages.props.
Verify target framework compatibility: xUnit.net v3 requires .NET 8+ or .NET Framework 4.7.2+. For test library projects, .NET Standard 2.0 is also supported. If any test projects have non-compatible target frameworks, STOP here — tell the user to upgrade the target framework first. Also verify the project uses SDK-style format.
Step 2: Update package references
Update any
PackageReferenceorPackageVersionitems for the new package names, based on the following mapping:xunit→xunit.v3xunit.abstractions→ Remove entirelyxunit.assert→xunit.v3.assertxunit.core→xunit.v3.corexunit.extensibility.coreandxunit.extensibility.execution→xunit.v3.extensibility.core(if both are referenced in a project consolidate to only a single entry as the two packages are merged)
- Update all
xunit.v3.*packages to the latest correct version available on NuGet. Also updatexunit.runner.visualstudioto the latest version.
Step 3: Set OutputType to Exe
In each test project (excluding test library projects), set OutputType to Exe in the project file:
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>Depending on the solution in hand, there might be a centralized place where this can be added. For example:
- If all test projects share (or can share) a common
Directory.Build.props, add the<OutputType>Exe</OutputType>property there. Note that the OutputType should not be added toDirectory.Build.targets. - If all test projects share a name pattern (e.g.,
*.Tests.csproj), add a conditional property group inDirectory.Build.propsthat applies only to those projects, like<OutputType Condition="$(MSBuildProjectName.EndsWith('.Tests'))">Exe</OutputType>. Adjust the condition as needed to target only test projects. - Otherwise, add the
<OutputType>Exe</OutputType>property to each test project file individually.
Step 4: Configure test platform
Preserve the same test platform that was used with xUnit.net v2. xUnit.net v2 always uses VSTest except if the project used YTest.MTP.XUnit2.
- If the project had a reference to
YTest.MTP.XUnit2:- Remove the reference to
YTest.MTP.XUnit2completely. - Add
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>toDirectory.Build.propsunder an unconditionalPropertyGroup.
- Remove the reference to
- If the project did NOT reference
YTest.MTP.XUnit2(the common case):- Add
<IsTestingPlatformApplication>false</IsTestingPlatformApplication>toDirectory.Build.propsunder an unconditionalPropertyGroup. IfDirectory.Build.propsdoesn't exist, create it. This keeps the project on VSTest.
- Add
Step 5: Remove Xunit.Abstractions usings
Find any using Xunit.Abstractions; directives in C# files and remove them completely.
Step 6: Address async void breaking change (if applicable)
In xUnit.net v3, async void test methods are no longer supported and will fail to compile. Search for any test methods declared with async void and change them to async Task. Test methods can be identified via the [Fact] or [Theory] attributes or other test attributes.
Step 7: Address breaking change of attributes (if applicable)
In xUnit.net v3, some attributes were updated so that they accept a System.Type instead of two strings (fully qualified type name and assembly name). These attributes are:
CollectionBehaviorAttributeTestCaseOrdererAttributeTestCollectionOrdererAttributeTestFrameworkAttribute
For example, [assembly: CollectionBehavior("MyNamespace.MyCollectionFactory", "MyAssembly")] must be converted to [assembly: CollectionBehavior(typeof(MyNamespace.MyCollectionFactory))].
Step 8: Inheriting from FactAttribute or TheoryAttribute (if applicable)
Identify if there are any custom attributes that inherit from FactAttribute or TheoryAttribute. These custom user-defined attributes must now provide source information. For example, if the attribute looked like this:
internal sealed class MyFactAttribute : FactAttribute
{
public MyFactAttribute()
{
}
}it must be changed to this:
internal sealed class MyFactAttribute : FactAttribute
{
public MyFactAttribute(
[CallerFilePath] string? sourceFilePath = null,
[CallerLineNumber] int sourceLineNumber = -1
) : base(sourceFilePath, sourceLineNumber)
{
}
}Step 9: Inheriting from BeforeAfterTestAttribute (if applicable)
Identify if there are any custom attributes that inherit from BeforeAfterTestAttribute. These custom user-defined attributes must update their method signatures. Previously, they would have Before/After overrides that look like this:
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
}it must be changed to this:
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
}Step 10: Address new xUnit analyzer warnings (if applicable)
xunit.v3 introduced new analyzer warnings. The most notable is xUnit1051 (use TestContext.Current.CancellationToken for methods accepting CancellationToken). Address these if present.
Step 11: Migrate Xunit.SkippableFact (if applicable)
If there are any package references to Xunit.SkippableFact, remove all these package references entirely.
Then, follow these steps to eliminate usages of APIs coming from the removed package reference:
- Update any
SkippableFactattribute to the regularFactattribute. - Update any
SkippableTheoryattribute to the regularTheoryattribute. - Change
Skip.Ifmethod calls toAssert.SkipWhen. - Change
Skip.IfNotmethod calls toAssert.SkipUnless.
Step 12: Update companion packages (if applicable)
Xunit.Combinatorial1.x → latest 2.xXunit.StaFact1.x → latest 3.x
Step 13: Build and verify
Build the solution and fix any remaining compilation errors. Run dotnet test to verify all tests pass with the same results as before migration.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

