csharp-mstest

Write MSTest 3.x/4.x unit tests with DataRow and DynamicData in C#.

Updated Dec 28, 2025
One-click install
npx skills add https://github.com/74nu5/Narratum --skill csharp-mstest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-mstest
Source: https://github.com/74nu5/Narratum/tree/main/.github/skills/csharp-mstest
Command: npx skills add https://github.com/74nu5/Narratum --skill csharp-mstest

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you write effective unit tests in C# using MSTest, ensuring your code is reliable and maintainable by leveraging modern assertion APIs and best practices.

Core Features & Use Cases

  • Modern Assertions: Utilize powerful and expressive assertion methods for various checks (equality, exceptions, collections, strings, types).
  • Data-Driven Tests: Easily create parameterized tests using DataRow and DynamicData for comprehensive test coverage.
  • Test Lifecycle Management: Understand and implement proper setup and teardown for tests using constructors and attributes.
  • Use Case: You need to write unit tests for a new C# class that performs calculations. This Skill will guide you on structuring your test class, writing individual test methods with clear assertions, and parameterizing tests for different input values.

Quick Start

Use the csharp-mstest skill to generate a basic MSTest unit test class for a C# method.

Frequently Asked Questions about csharp-mstest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write parameterized unit tests in C# using MSTest?

Parameterized unit tests in MSTest use the DataRow attribute for inline values or DynamicData for complex types to drive data-driven tests. This approach allows you to run a single test method multiple times with different inputs to verify various scenarios comprehensively.

How do I assert that a C# method throws a specific exception in MSTest?

Asserting exceptions in MSTest involves using the modern assertion APIs to verify that a specific action throws the expected exception type. This ensures your error handling logic works correctly and fails gracefully under invalid conditions.

What is the best way to manage test setup and teardown in MSTest?

Test setup and teardown in MSTest are managed using constructors for initialization and specific lifecycle attributes for cleanup. Proper lifecycle management ensures each test runs independently with a clean state, preventing cross-test contamination.

Can I use MSTest for comprehensive string and collection assertions in .NET?

MSTest provides modern assertion APIs specifically designed for comprehensive checks on strings, collections, equality, and types in .NET. These expressive methods help validate data structures and outputs thoroughly without writing custom validation logic.

Does MSTest 3.x support modern C# unit testing best practices?

MSTest 3.x and 4.x support modern C# unit testing best practices by offering robust test class structures and advanced assertion APIs. This ensures your tests remain maintainable, efficient, and aligned with current .NET development standards.

Why are my MSTest data-driven tests not recognizing DynamicData inputs?

DynamicData inputs in MSTest require properly configured method or property references to supply test parameters correctly. If the data source is not static or the attribute arguments are mismatched, the test framework cannot populate the test method parameters.