Agent skill · software engineering · github
csharp-mstest
Get best practices for MSTest 3.x/4.x unit testing, including modern assertion APIs and data-driven tests
Why this skill is useful
Provides specific best practices and modern assertion patterns for MSTest that the AI wouldn't reliably generate on its own.
What it needs
About 6k tokens when loaded. Last updated 2026-08-07. 37,534 stars on the source repository.
What this skill does
MSTest Best Practices (MSTest 3.x/4.x) Your goal is to help me write effective unit tests with modern MSTest, using current APIs and best practices. Project Setup Use a separate test project with naming convention [ProjectName].Tests Reference MSTest 3.x+ NuGet packages (includes analyzers) Consider using MSTest.Sdk for simplified project setup Run tests with dotnet test Test Class Structure Use [TestClass] attribute for test classes Seal test classes by default for performance and design clarity Use [TestMethod] for test methods (prefer over [DataTestMethod]) Follow Arrange-Act-Assert (AAA) pattern Name tests using pattern MethodNameScenarioExpectedBehavior Test Lifecycle Prefer constructors over [TestInitialize] - enables readonly fields and follows standard C# patterns Use [TestCleanup] for cleanup that must run even if test fails Combine constructor with async [TestInitialize] when async setup is needed Execution Order 1. Assembly Initialization - [AssemblyInitialize] (once per test assembly) 2. Class Initialization - [ClassInitialize] (once per test class) 3. Test Initialization (for every test method): 1. Constructor 2. Set TestContext property 3. [TestInitialize] 4. Test Execution - test method runs 5. Test Cleanup (for every test method): 1. [TestCleanup] 2. DisposeAsync (if implemented) 3. Dispose (if implemented) 6. Class Cleanup - [ClassCleanup] (once per test class) 7. Assembly Cleanup - [AssemblyCleanup] (once per test assembly) Modern Assertion APIs MSTest provides three assertion classes: Assert, StringAssert, and CollectionAssert. Assert Class - Core Assertions Exception Testing (Prefer over [ExpectedException]) Collection Assertions (Assert class) String Assertions (Assert class) Comparison Assertions Type Assertions Assert.That (MSTest 4.0+) StringAssert Class Note: Prefer Assert class equivalents when available (e.g., Assert.Contains("expected", actual) over StringAssert.Contains(actual, "expected")). …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills github/csharp-mstest