Skip to main content
skill CX Codex

mstest-skill — Claude Code skill: tests and install

This skill generates MSTest unit tests in C# for .NET. Use it when a task calls for [TestMethod], assertion checks, or data-driven cases.

MIT 209 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill mstest-skill -a claude-code
Open on GitHub

What mstest-skill does

mstest-skill guides an agent in writing tests with Microsoft’s built-in MSTest framework for C#. It covers test classes and methods, setup hooks such as [TestInitialize], parameterized cases with [DataTestMethod] and [DataRow], plus dynamic data from a method.

The skill includes patterns for assertions, exception checks, test lifecycle hooks, categories, skipped tests, and time limits. Its reference/playbook.md adds material on project setup, WebApplicationFactory, generated test data, logging, and CI/CD integration.

The project needs MSTest.TestFramework, MSTest.TestAdapter, and Microsoft.NET.Test.Sdk; the README gives dotnet add package MSTest.TestFramework MSTest.TestAdapter Microsoft.NET.Test.Sdk for setup. Run the suite with dotnet test, or select a category with dotnet test --filter "TestCategory=Smoke". Without those packages, the MSTest examples cannot run.

What it helps with

  • write MSTest tests for a C# class
  • verify that an invalid call throws
  • cover inputs with [DataRow] cases
  • mark tests with a category
  • run only tests matching a filter

Example prompts for the agent

  • Create MSTest tests for Calculator, including addition and division by zero.
  • Add a data-driven test with [DataTestMethod] and several [DataRow] cases.
  • Set the tests to the Smoke category and show the command dotnet test --filter "TestCategory=Smoke".

How to install mstest-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill mstest-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/mstest-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/mstest-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about mstest-skill

How do I install mstest-skill in Claude Code?

Run npx skills add LambdaTest/agent-skills --skill mstest-skill -a claude-code, then check ~/.claude/skills/mstest-skill/SKILL.md.

What does mstest-skill do?

It helps generate MSTest tests in C# for .NET, including regular and parameterized methods, exception checks, categories, and lifecycle setup.

What is required to run the MSTest tests?

Add MSTest.TestFramework, MSTest.TestAdapter, and Microsoft.NET.Test.Sdk, then run dotnet test. To select a category, use dotnet test --filter "TestCategory=Smoke".

Source text

SKILL.md · MIT
---
name: mstest-skill
description: >
  Generates MSTest tests in C#. Microsoft's built-in testing framework for .NET.
  Use when user mentions "MSTest", "[TestMethod]", "[TestClass]",
  "Assert.AreEqual". Triggers on: "MSTest", "[TestMethod]", "[TestClass]",
  "Microsoft test framework".
languages:
  - C#
category: unit-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# MSTest Testing Skill

## Core Patterns

### Basic Test

```csharp
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class CalculatorTests
{
    private Calculator _calc;

    [TestInitialize]
    public void SetUp() => _calc = new Calculator();

    [TestMethod]
    public void Add_TwoNumbers_ReturnsSum()
    {
        Assert.AreEqual(5, _calc.Add(2, 3));
    }

    [TestMethod]
    [ExpectedException(typeof(DivideByZeroException))]
    public void Divide_ByZero_Throws()
    {
        _calc.Divide(10, 0);
    }
}
```

### Data-Driven Tests

```csharp
[DataTestMethod]
[DataRow(2, 3, 5)]
[DataRow(-1, 1, 0)]
[DataRow(0, 0, 0)]
public void Add_Parameterized(int a, int b, int expected)
{
    Assert.AreEqual(expected, _calc.Add(a, b));
}

[DataTestMethod]
[DynamicData(nameof(GetTestData), DynamicDataSourceType.Method)]
public void Add_DynamicData(int a, int b, int expected)
{
    Assert.AreEqual(expected, _calc.Add(a, b));
}

private static IEnumerable<object[]> GetTestData()
{
    yield return new object[] { 1, 2, 3 };
    yield return new object[] { 10, -5, 5 };
}
```

### Assertions

```csharp
Assert.AreEqual(expected, actual);
Assert.AreNotEqual(unexpected, actual);
Assert.IsTrue(condition);
Assert.IsFalse(condition);
Assert.IsNull(obj);
Assert.IsNotNull(obj);
Assert.IsInstanceOfType(obj, typeof(MyClass));
Assert.ThrowsException<ArgumentException>(() => Method());
CollectionAssert.Contains(list, item);
CollectionAssert.AreEquivalent(expected, actual);
StringAssert.Contains(str, "substring");
StringAssert.StartsWith(str, "prefix");
StringAssert.Matches(str, new Regex(@"\d+"));
```

### Lifecycle

```
[AssemblyInitialize]  → Once per assembly (static)
[ClassInitialize]     → Once per class (static)
[TestInitialize]      → Before each test
[TestMethod]          → Test
[TestCleanup]         → After each test
[ClassCleanup]        → Once after class (static)
[AssemblyCleanup]     → Once after assembly (static)
```

### Categories

```csharp
[TestMethod, TestCategory("Smoke")]
public void QuickTest() { }

[TestMethod, Ignore("Bug #456")]
public void SkippedTest() { }

[TestMethod, Timeout(5000)]
public void TimedTest() { }
```

## Setup: `dotnet add package MSTest.TestFramework MSTest.TestAdapter Microsoft.NET.Test.Sdk`
## Run: `dotnet test` or `dotnet test --filter "TestCategory=Smoke"`

## Deep Patterns

See `reference/playbook.md` for production-grade patterns:

| Section | What You Get |
|---------|-------------|
| §1 Project Setup | .csproj deps, .runsettings with parallel + coverage config |
| §2 Test Patterns | TestMethod, DataTestMethod, DynamicData, exception testing |
| §3 FluentAssertions | AssertionScope, async exceptions, collection assertions |
| §4 Class & Assembly Initialize | Testcontainers, shared expensive setup, global config |
| §5 WebApplicationFactory | API integration tests with in-memory DB |
| §6 Bogus Test Data | Faker patterns for realistic data generation |
| §7 TestContext & Logging | Diagnostic output, categories, timeouts |
| §8 CI/CD Integration | GitHub Actions with coverage reporting and thresholds |
| §9 Debugging Table | 12 common problems with causes and fixes |
| §10 Best Practices | 14-item production checklist |

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
testcafe-skill Generate TestCafe end-to-end tests in JavaScript or TypeScript, from login flows to selector checks. The skill covers local runs and TestMu AI Cloud. CX Codex +1 212installs geb-skill This skill generates browser automation tests in Groovy using Geb and Spock. It provides page object patterns and jQuery-like selectors for e2e testing. CX Codex +1 211installs capybara-skill Generates acceptance tests for web apps using Capybara and RSpec. Use it to automate clicks, form fills, and page assertions in Ruby-based E2E suites. CX Codex +1 210installs nunit-skill Generates C# unit tests for NUnit 3 using the Assert.That constraint model, parameterized inputs, and Moq mocks. CX Codex +1 210installs nemojs-skill The nemojs-skill skill generates JavaScript automation tests for Nemo.js and Selenium. Use it for browser flows such as login checks, element waits, and assertions. CX Codex +1 209installs lettuce-skill Generates Python BDD tests using the legacy Lettuce framework. Builds Gherkin feature files, step definitions, and terrain hooks for existing test suites. CX Codex +1 208installs nightwatchjs-skill Writes NightwatchJS E2E tests in JavaScript or TypeScript, with page objects and built-in assertions. Fits repos that already run Nightwatch. CX Codex +1 208installs protractor-skill protractor-skill is a Claude Code skill that writes Protractor E2E tests for Angular and AngularJS apps in JavaScript or TypeScript. It activates on requests about Protractor, element(by.model()), or Angular E2E testing. CX Codex +1 206installs

Project sponsors

Companies that keep this analytics open