writing-mstest-tests

Featured

Best practices for writing MSTest 3.x/4.x unit tests. Use when the user needs to write, improve, fix, or review MSTest tests, including modern assertions, data-driven tests, test lifecycle, and common anti-patterns. Also use when fixing test issues like swapped Assert.AreEqual arguments, incorrect assertion usage, or modernizing legacy test code. Covers MSTest.Sdk, sealed classes, Assert.Throws, DynamicData with ValueTuples, TestContext, and conditional execution.

Testing & QA 6,272 stars 499 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Writing MSTest Tests Help users write effective, modern unit tests with MSTest 3.x/4.x using current APIs and best practices. ## When to Use - User wants to write new MSTest unit tests - User wants to improve or modernize existing MSTest tests - User asks about MSTest assertion APIs, data-driven patterns, or test lifecycle - User needs to review MSTest test code for anti-patterns ## When Not to Use - User needs to run or execute tests (use the `run-tests` skill) - User needs to upgrade from MSTest v1/v2 to v3 (use `migrate-mstest-v1v2-to-v3`) - User needs to upgrade from MSTest v3 to v4 (use `migrate-mstest-v3-to-v4`) - User needs CI/CD pipeline configuration - User is using xUnit, NUnit, or TUnit (not MSTest) ## Inputs | Input | Required | Description | |-------|----------|-------------| | Code under test | No | The production code to be tested | | Existing test code | No | Current tests to review or improve | | Test scenario description | No | What behavior the user wants to test | ## Workflow ### Step 1: Determine project setup Check the test project for MSTest version and configuration: - If using `MSTest.Sdk` (`<Sdk Name="MSTest.Sdk">`): modern setup, all features available - If using `MSTest` metapackage: modern setup (MSTest 3.x+) - If using `MSTest.TestFramework` + `MSTest.TestAdapter`: check version for feature availability Recommend MSTest.Sdk or the MSTest metapackage for new projects: ```xml <!-- Option 1: MSTest SDK (simplest, recommended for new p...

Details

Author
dotnet
Repository
dotnet/skills
Created
9 months ago
Last Updated
today
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category