MSTest — Exécuteur de tests .NET filtré

VérifiéPrudence

Exécute les tests backend avec sortie filtrée (noms des tests réussis/échoués, messages d'erreur).

Spar Skills Guide Bot
TestingIntermédiaire
25/07/2026
Claude Code
#mstest#dotnet#test-runner#filtered-output#powershell

Recommandé pour

Synthèse automatique

Lance les tests backend .NET via MSTest en n'affichant que les noms de tests réussis/échoués, les messages d'erreur et le résumé, à travers une file d'attente de build PowerShell.

Points forts

  • Sortie filtrée qui réduit fortement le bruit par rapport à un dotnet test brut
  • Prise en charge des filtres MSTest (ClassName~, Name~, FullyQualifiedName~) et du choix de la DLL de test
  • Gestion explicite des runs longs : timeout de 10 min, exécution en arrière-plan et helper d'attente qui réémet un banner de résultat faisant autorité
  • Sérialisation via la file de build, ce qui évite les collisions avec les compilations concurrentes

Limites

  • Très lié à un dépôt précis : noms de projets Cognito, manifeste .claude/skill-config/build-queue-ops.json et scripts dans $HOME/.claude/scripts
  • Dépend de PowerShell sous Windows et ne fonctionne pas tel quel sur un autre dépôt sans adaptation
  • Lance avec --no-build : il faut compiler d'abord (par exemple via /msbuild), sinon les résultats peuvent être obsolètes
Quand l'utiliser

Utilisez-le lorsque vous devez exécuter rapidement des tests unitaires .NET ciblés et ne lire que l'essentiel : échecs, erreurs et résumé.

Quand l'éviter

Ne l'utilisez pas pour déboguer en profondeur un test qui échoue (il ne reformate ni n'interprète la sortie) ni sur un projet .NET qui n'est pas équipé de la file de build et des scripts attendus.

Analyse de sécurité

Prudence
Score qualité88/100

The skill is a test-runner wrapper and does not itself perform destructive, exfiltrating, or obfuscated actions. However, it invokes PowerShell with ExecutionPolicy Bypass, appends user arguments verbatim, and relies on local scripts that are not part of the catalog entry, making it a powerful local execution surface that merits caution rather than a clean safe rating.

Points d'attention
  • •Uses `powershell.exe -ExecutionPolicy Bypass` to run local scripts, which weakens PowerShell execution policy for the invocation.
  • •Appends `$ARGUMENTS` verbatim to the PowerShell command, creating a potential argument-injection surface if untrusted input is supplied.
  • •Depends on external scripts under `$HOME/.claude/scripts` and repo-local ops manifest not included in the skill, so behavior depends on opaque local code.
Comment cette analyse est faite

Exemples

Run all unit tests
/mstest
Run a filtered test class
/mstest -Filter "ClassName~PersonSubmissionIndexingTests"
Filtered Selenium browser tests
/mstest -TestDll "Cognito.Forms.UnitTests" -Filter "ClassName~Foo"

name: mstest description: Run backend tests with filtered output (pass/fail + errors only). Wraps test-filtered.ps1. argument-hint: [-Filter "ClassName~Foo"] [-TestDll "Cognito.Forms.UnitTests"] model: haiku allowed-tools: ["Bash"]

MSTest — Filtered .NET Test Runner

Run backend tests showing only passed/failed test names, error messages, and summary. Runs with --no-build — build first if needed. For a fast targeted compile of just the project under test, run /msbuild -Project "<relative/path/to.csproj>" before this (both stay serialized through the build queue).

Usage

  • /mstest — run all unit tests (Cognito.UnitTests — this is where ALL service/unit tests live)
  • /mstest -Filter "ClassName~MyTestClass" — run filtered tests
  • /mstest -TestDll "Cognito.Forms.UnitTests" — run Selenium/browser integration tests (NOT service tests)
  • /mstest -TestDll "Cognito.Forms.UnitTests" -Filter "ClassName~Foo" — filtered browser tests

Important: Cognito.UnitTests contains all service-level tests (EntryIndexServiceTests, PersonSubmissionIndexingTests, ShouldInvalidateIndexTests, etc.). Cognito.Forms.UnitTests is only for Selenium browser tests. When in doubt, use the default (no -TestDll flag).

Filter Syntax

MSTest filter expressions: ClassName~Foo, Name~Bar, FullyQualifiedName~Baz

Instructions

  1. Construct the command:

    powershell.exe -ExecutionPolicy Bypass -File "$HOME/.claude/scripts/build-queue.ps1" -Op mstest
    

    The mstest op is registered in this repo's ops manifest (.claude/skill-config/build-queue-ops.json — the queue's per-repo op registry), which is the authoritative source of the exec script (test-filtered.ps1). Do NOT pass -Exec — the manifest resolves it. (-Exec remains an optional override; a passed-or-manifest exec that does not exist now fails fast with a distinct exec script not found error before anything is enqueued.)

  2. If $ARGUMENTS is provided, append it verbatim to the command. The script accepts:

    • -Filter "..." — MSTest filter expression
    • -TestDll "..." — test project name without extension (default: Cognito.UnitTests)
  3. Run the command using Bash with timeout: 600000 (10 min). A test run can legitimately exceed the default 2-min Bash timeout; the higher ceiling costs nothing for fast runs because Bash returns as soon as the command exits. Do not interpret or reformat the output. The invocation prints an authoritative one-line build-queue: seq=<N> op=mstest RESULT=<PASS|FAIL|NO-TESTS-MATCHED> tests=<T> failed=<F> (result_fidelity=...) banner as its LAST stdout line — trust that line for the outcome. Do NOT cat/grep the runner script (build-queue-runner.ps1) or results/<seq>.json to disambiguate an exit_code=0. See the exit-code guidance below for the banner's next-actions. ETA note: the enqueue echo and waiting-position lines may carry advisory predictions (eta-start≈ / eta-done≈, ? when history is cold) computed from recent run durations. They are predictions, never outcomes — the authoritative outcome remains the final build-queue: ... RESULT= banner line.

  4. If the run is expected to exceed 10 minutes, run the same command with run_in_background: true instead. The build-queue: enqueued as seq=N line it returns is NOT an outcome — never end your turn or report a result on it. Follow the run to its authoritative result with the await helper (foreground Bash, timeout: 600000):

    powershell.exe -ExecutionPolicy Bypass -File "$HOME/.claude/scripts/build-queue-await.ps1" -Seq <N>
    

    It blocks until results/<seq>.json exists, re-emits the same authoritative build-queue: seq=<N> op=mstest RESULT=... banner as its LAST stdout line, and exits with the run's exit code. On its distinct await-timeout exit (124, result not yet present for seq=N) the run is still going — re-run the helper or check /build-queue-status; NEVER treat a timeout as success, and do not hand-read results/<seq>.json instead.

    Foreground-timeout recovery: if a foreground run is killed by the 10-min Bash timeout before the banner prints, recover the seq from the build-queue: enqueued as seq=N line already in the output and run the same await helper — do NOT re-enqueue the run.

Log files: <seq>.build.log vs <seq>.log

Test-run output for this op lands in ~/.claude/state/build-queue/logs/<seq>.log. But when a red run traces back to a build problem (e.g. the stale-DLL exit 4 below sends you to /msbuild), note that a build op's real transcript is that seq's <seq>.build.log (stderr: <seq>.build.err.log) — for build ops the sibling <seq>.log is the runner's own near-empty log, not the build output.

Stale-DLL trap (--no-build)

Because this skill runs --no-build, a red result can be bogus if the DLL under test is stale — e.g. the last build silently lost a DLL copy race (MSB3027 copy-lock). test-filtered.ps1 now guards against this: it emits a staleness WARN and exits 4 when the target test DLL is missing, predates its source (.cs/.csproj) files, or the last build's hygiene recorded build_fidelity: log-failure-override. (Other distinct exit codes: 1 = not in a git repo, 3 = zero test output captured, 5 = filter matched zero tests.)

On the staleness WARN / exit 4 (banner RESULT=FAIL): rebuild with /msbuild before trusting a red. A failing test against a stale DLL is not a real failure — rebuild, then re-run /mstest.

On banner RESULT=NO-TESTS-MATCHED (exit 5): the filter matched zero tests — widen the -Filter and re-run. A zero-match run is not a pass; the banner distinguishes it from a real all-pass (result_fidelity=no-tests-matched vs verified), so trust the banner rather than reading a bare exit_code.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/mstest-filtered-net-test-runner-mrzxuqhn/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/mstest-filtered-net-test-runner-mrzxuqhn' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/mstest-filtered-net-test-runner-mrzxuqhn/download' --output '.skill-downloads/mstest-filtered-net-test-runner-mrzxuqhn/SKILL.md.part' && mv '.skill-downloads/mstest-filtered-net-test-runner-mrzxuqhn/SKILL.md.part' '.skill-downloads/mstest-filtered-net-test-runner-mrzxuqhn/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Le fichier ne fournit pas un en-tête name/description exploitable pour cette procédure native. Le téléchargement reste disponible pour lecture ; utilisez le mode manuel ci-dessous.

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/mstest-filtered-net-test-runner-mrzxuqhn/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires