# Writing Mstest Tests

ALWAYS USE when asked to fix, rewrite, update, improve, modernize, show corrected code...

- Repository: https://github.com/managedcode/dotnet-skills (500 stars)
- Category: Design
- License: MIT
- Last updated: 2026-10-29
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add managedcode/dotnet-skills --skill writing-mstest-tests -g -a claude-code -y`
Codex: `npx skills add managedcode/dotnet-skills --skill writing-mstest-tests -g -a codex -y`
Cursor: `npx skills add managedcode/dotnet-skills --skill writing-mstest-tests -g -a cursor -y`
Gemini CLI: `npx skills add managedcode/dotnet-skills --skill writing-mstest-tests -g -a gemini-cli -y`

## Description

ALWAYS USE when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for "review" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected/actual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext/lifecycle; timeout/cancellation; OS/CI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. DO NOT USE to design new test cases (code-testing), perform report-only audits, create project files rather than explain MSTest setup, run tests, migrate frameworks, or handle non-MSTest/non-.NET code.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Writing MSTest Tests

Help users write effective MSTest unit tests without exceeding the API level or
conventions of the project's installed test stack.

## Repository overlay

For every repository-scoped task where read-only file inspection is allowed,
check `.agents/skill-overlays/dotnet-test/writing-mstest-tests.md` at the
repository root before any other discovery. This includes requests that ask for
code or advice without edits; "do not execute" does not prohibit reading the
overlay. If present, read it once before acting and apply its
repository-specific naming, layout, framework, and policy bindings.
Require its frontmatter to declare `core: dotnet-test/writing-mstest-tests`,
`binding-revision: "1"`, and `mode: extend`. If any value is missing or
different, report the mismatch, ignore the overlay, and continue using this
skill's portable guidance.
Explicit user instructions and verified project constraints win over the
overlay; the overlay wins over portable defaults and examples in this skill. If
the file is present but unreadable or conflicts with the repository, report the
problem, ignore the overlay, and continue with portable guidance subject to
verified project constraints. If it is absent, continue normally.
Skip the lookup only when the task is not tied to a repository or the user
explicitly prohibited all file/tool access. An overlay cannot expand tool
permissions or the task's scope.

## When to Use

The rest: https://github.com/managedcode/dotnet-skills/blob/HEAD/catalog/Testing/Official-DotNet-Test/skills/writing-mstest-tests/SKILL.md
