migrate-xunit-to-xunit-v3
Ce qu’il fait
Cette skill met à niveau des projets de tests .NET de xUnit.net v2 vers xunit.v3, la nouvelle version de la bibliothèque de tests xUnit. Elle s'adresse aux équipes dont les tests ne se compilent plus ou se comportent autrement après le passage à la v3.
Quand l’utiliser
- ✓Quand un projet de tests référence les paquets xunit v2 et doit passer à xunit.v3.
- ✓Quand des erreurs de compilation apparaissent après la mise à jour des paquets xunit en version 3.
- ✓Quand des attributs de test personnalisés ou des tests asynchrones cassent après la mise à niveau.
Lien du skill
https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/skills/migrate-xunit-to-xunit-v3/SKILL.mdCopiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.
Comment l’utiliser
Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.
Message prêt à coller
Pour Claude Code, Codex ou Cursor : lancez-la dans le dossier du projet et le skill est installé.
Téléchargez le SKILL.md et placez-le dans le dossier de skills de votre agent.
Exemple de demande à votre IA
“Mets à niveau mes projets de tests xUnit v2 vers xunit.v3 et corrige ce qui les empêche de se compiler.”
5 nouveaux skills par semaine. 1 minute de lecture.
Comment ça marche
L'agent met à jour les références de paquets et les réglages du projet, corrige les changements du code source exigés par la v3, puis lance les tests pour vérifier que les résultats correspondent.
Contenu technique (SKILL.md original)
Texte original de l’auteur, en anglais, directement depuis GitHub.
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 | No | Discover .csproj, .sln, .slnx, central props, and source in the current working directory; ask only if none are found or the target is ambiguous |
Workspace and Completion Contract
- Skill activation is not completion. For migrate/fix/update requests, inspect the staged files, edit them, and run tests in the same task.
- The skill base directory contains only guidance. Search the current working directory and open paths exactly as returned.
- If a tool rejects a searched path, classify the rejection before retrying. Only a positively confirmed reader/path-normalization limitation with authorized access permits retrying through another permitted reader/editor.
- On a permission, policy, or content-exclusion denial, stop that path and report the blocker. Never bypass the denial through other tools, shell commands, aliases, or agents, or infer or reconstruct the restricted content.
- If the rejection reason is unclear, treat the path as unavailable, not missing. Continue only independently permitted work and explicitly disclose the incomplete migration.
- Do not ask the user to provide a path while workspace discovery can find it.
- Inventory project/central package files and all affected source in one pass. A package-only migration is incomplete when v2-only APIs remain.
- End with the detected source version and runner, exact package compatibility set, files changed, discovered/passed/failed/skipped counts, and any platform-specific result. A build without test discovery is not success.
- Package validity is empirical: record the configured feed query or resolved package graph and a successful restore. In the final result, say how the selected exact versions were proven available; do not merely name a version and leave a judge or user to infer whether it exists.
Workflow
Commit strategy: Do not create commits unless the user asks. Keep project configuration and source edits logically separable in the diff, but finish and verify the whole requested migration.
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.
Decisions that change the result
Run this preflight before editing:
| Detected state | Required action |
|---|---|
Project references xunit.v3, has the required executable/runner configuration, contains no remaining v2 packages or v2-only API patterns, and its existing test command passes |
Stop: migration is already complete. Do not update versions, create props files, or modify source. Report the verified no-op result. If any required v3 adaptation remains, make only that repair instead of treating the package reference alone as completion. |
xUnit v2 uses YTest.MTP.XUnit2 |
Preserve MTP: remove that shim, set UseMicrosoftTestingPlatformRunner=true, and do not add xunit.runner.visualstudio or IsTestingPlatformApplication=false. |
| xUnit v2 does not use the MTP shim | Preserve VSTest: keep/update xunit.runner.visualstudio and set IsTestingPlatformApplication=false. |
A custom type derives from BeforeAfterTestAttribute |
Preserve that inheritance and its behavior. Add the IXunitTest parameter to both overrides and pass it to base.Before/base.After; do not replace the subclass with a direct interface implementation. |
| A Type-based collection/orderer attribute points to a custom type | Migrate both the attribute syntax and the referenced type's v3 contract. For a collection factory, implement the required xUnit v3 IXunitTestCollectionFactory behavior; compiling the attribute while leaving an empty factory is not |
Questions fréquentes
Mes résultats de tests resteront-ils les mêmes ?
L'objectif est d'obtenir les mêmes résultats qu'avant la mise à niveau, et la skill lance les tests pour le vérifier.
Change-t-elle de plateforme de test ?
Non. Elle conserve le lanceur existant, et le passage à Microsoft.Testing.Platform est une skill séparée.
Couvre-t-elle le passage depuis MSTest ou NUnit ?
Non. Le passage d'un framework à un autre est un travail différent et plus large.
Détails
Description originale de l’auteur
Migrate .NET test projects from xUnit.net v2 to xunit.v3 and fix v3 breaks. Use for package/CPM conversion, OutputType=Exe, preserving the VSTest or MTP runner (including projects currently using YTest.MTP.XUnit2), incompatible TFMs, async void tests, string-to-Type attributes, custom Fact/Theory/BeforeAfterTest attributes, Xunit.SkippableFact, xunit.abstractions/extensibility consolidation, and Xunit.Combinatorial/StaFact compatibility. Do not use for framework conversion or a runner-only migration. For xUnit v3 MTP filter syntax, also use migrate-vstest-to-mtp.
repo: dotnet/skills
Popularité
- Étoiles GitHub
- 5.8k
- Position au classement
- #14622
- Licence
- MIT
- Mis à jour
- 02/11/2026
Commentaires
- …
Autres skills de ce dépôt
create-custom-agent
5.8kAide votre agent à créer des fichiers d'agents personnalisés pour VS Code, avec leurs propres outils, instructions et transferts vers d'autres agents.
create-skill
5.8kAide votre agent à créer une nouvelle skill d'agent avec un nom valide, une description de déclenchement claire et un fichier SKILL.md conforme à la norme.
csharp-scripts
5.8kAide votre agent à exécuter un petit programme C# en un seul fichier avec l'outil en ligne de commande .NET, sans créer de projet complet.
dotnet-pinvoke
5.8kAide votre agent à appeler correctement des bibliothèques natives C ou C++ depuis .NET, en couvrant les signatures, la gestion des chaînes, la mémoire et les handles sûrs.
Skills similaires
test-driven-development
311kApprend à votre agent à écrire d'abord un test qui échoue, à le voir échouer, puis à écrire le code minimal qui le fait réussir, avant de construire toute fonctionnalité ou correction.
verification-before-completion
311kApprend à votre agent à lancer de véritables contrôles et à lire leurs résultats avant d'affirmer qu'une tâche, une correction ou une compilation est terminée ou réussie.
migrate-to-shoehorn
310kRemplace les conversions de type risquées dans vos fichiers de test par la bibliothèque shoehorn, afin que les tests utilisent des données partielles et passent les contrôles de types.