Aller au contenu
Skillpedia
Tests5.8k · #14621

migrate-xunit-to-mstest

Ce qu’il fait

Cette skill convertit les tests xUnit.net d'un projet .NET en MSTest v4 sans changer ce que les tests vérifient. Elle s'adresse aux équipes qui veulent passer de xUnit à MSTest et conserver le même comportement.

Quand l’utiliser

  • ✓Quand un projet de tests .NET utilise xUnit et que vous voulez le passer à MSTest.
  • ✓Quand vous voulez remplacer les attributs, fixtures et assertions xUnit par leurs équivalents MSTest.
  • ✓Quand une demande de conversion de xUnit vers MSTest est peut-être déjà en partie faite et doit être vérifiée.

Lien du skill

https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest/SKILL.md

Copiez-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

Utilise ce skill pour m’aider : https://github.com/dotnet/skills/blob/main/plugins/dotnet-test-migration/skills/migrate-xunit-to-mstest/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Convertis mes tests xUnit en MSTest v4 et confirme qu'ils réussissent toujours avec les mêmes résultats.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'agent repère les paquets et attributs xUnit, les convertit en équivalents MSTest, puis compile le projet et lance les tests pour confirmer les mêmes résultats.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

xUnit -> MSTest Migration

Convert xUnit.net v2 or v3 tests to MSTest v4 without changing the target framework or test platform. A successful migration builds, discovers the same tests, and preserves pass/fail results and execution semantics.

Scope

Use this skill only when the project contains xUnit packages or source and the user wants MSTest. If the project already uses MSTest and contains no xUnit tests, report that no framework migration is needed and make no changes.

Do not combine this framework conversion with a target-framework upgrade or VSTest/MTP migration. Complete and verify one migration before starting another.

Workspace Contract

  • Continue after skill activation. Search the current working directory for the staged project and source; never look for user files under this skill's base directory.
  • Open the literal paths returned by glob/search. If one reader or patch tool rejects a path that was just found, retry with another available tool. Do not ask the user for a path until current-workspace discovery is exhausted.
  • Classify by the requested deliverable: "convert this project" means edit, build, and test; "give me a plan" or "how would I convert it?" means answer. Do not replace execution with "please provide the files" when files are present.
  • The final response must state the source xUnit version, preserved runner, changed files, each high-risk semantic mapping applied, and actual test counts. Assertions about fixture lifetime, Owner mapping, cancellation, or parallelization must be visible in the resulting source, not only prose.

Response Mode

  • Full migration request: inspect the project, make the edits, build, and run tests. Do not stop after giving a plan.
  • Focused compile error or API question: inspect the relevant code and apply only that mapping. Do not narrate the entire workflow.
  • Unsupported target framework: stop before changing packages. MSTest v4 requires .NET 8+ or .NET Framework 4.6.2+ for test applications; offer a separately approved TFM upgrade or MSTest v3 as the intermediate target.

Decisions That Change the Result

Apply these before the mechanical mapping:

Detected state Required action
No xUnit package, namespace, attribute, or fixture remains Stop. Make no file changes, report that migration is unnecessary, and run the existing dotnet test command once to prove the already-MSTest project is healthy.
Source uses VSTest Keep the existing VSTest property/configuration. Prefer retaining and updating a source project's explicit Microsoft.NET.Test.Sdk pin; a repository that intentionally relies on the MSTest metapackage's transitive dependency may keep that convention. Do not introduce MTP properties.
Source uses MTP Replace xUnit-specific MTP selection with MSTest MTP configuration. Prefer MSTest.Sdk; with the metapackage, set EnableMSTestRunner=true and OutputType=Exe. Preserve native-versus-bridged command integration, and do not add <UseVSTest>true</UseVSTest> or other VSTest-only configuration.
Source relies on xUnit's default parallelization Add [assembly: Parallelize(Workers = 0, Scope = ExecutionScope.ClassLevel)] to a compiled .cs file when the current project has at least two independently runnable test classes. In a one-class project with no explicit parallel setting, omit it because class-level concurrency is not observable. Translate explicit CollectionBehavior or xunit.runner.json settings regardless of current class count. Before reporting completion, read the changed file back and name it in the result.

For detailed mappings and examples, search references/mapping-cheatsheet.md for constructs actually present in the project and read only the matching sections. Do not load or reproduce the whole reference.

Fast Path

For a routine project migration, converge in four phases: one batched discovery read/search, one edit pass, one dotnet test, and one concise result. Do not:

  • list a directory and then reread the same files through another tool
  • copy project files into the loaded skill or its references/ directory; those files are read-only guidance, not an editing workspace
  • try dotnet test --no-restore unless restore is already known to be current
  • run separate restore, build, and test commands when dotnet test is sufficient
  • rerun a passing test command or inspect unchanged files for confirmation
Questions fréquentes

Met-elle aussi à niveau la cible .NET ?

Non. Le changement de framework cible est séparé du passage de framework de test.

Garde-t-elle le même lanceur de tests ?

Oui. La skill conserve le lanceur que le projet utilise déjà.

Et si je veux seulement un plan ?

La skill répond par un plan lorsque c'est ce que vous demandez, et ne fait alors aucune modification.

Détails

Description originale de l’auteur

Convert .NET tests from xUnit.net v2/v3 to MSTest v4 while preserving VSTest or MTP. Use for replacing xunit packages, Fact/Theory/InlineData/MemberData, assertions, IClassFixture/ICollectionFixture, ITestOutputHelper, TestContext cancellation, traits/Owner, skips, timeouts, and xUnit parallelization. Also use when a "convert xUnit to MSTest" request may already be migrated: inspect and report the no-op. Do not use for xUnit v2-to-v3, MSTest upgrades, NUnit/TUnit conversion, or runner-only VSTest-to-MTP migration.

repo: dotnet/skills

Popularité

Étoiles GitHub
5.8k
Position au classement
#14621
Licence
MIT
Mis à jour
02/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires