csharp-nunit

Installation
Summary

NUnit best practices for standard and data-driven unit testing in .NET projects.

  • Organize tests with [TestFixture] classes matching production code, using [Test] methods named MethodName_Scenario_ExpectedBehavior and following Arrange-Act-Assert structure
  • Data-driven testing via [TestCase], [TestCaseSource], [Values], [Range], and [Combinatorial] attributes for inline, programmatic, and parameterized test generation
  • Use Assert.That with constraint model (Is.EqualTo, Contains.Item) and specialized assertions like CollectionAssert, StringAssert, and Assert.Throws<T> for exceptions
  • Manage test lifecycle with [SetUp], [TearDown], [OneTimeSetUp], and [OneTimeTearDown] for per-test and per-class initialization
  • Keep tests focused, independent, and idempotent; use [Category], [Order], and [Explicit] for organization and execution control
SKILL.md

NUnit Best Practices

Your goal is to help me write effective unit tests with NUnit, covering both standard and data-driven testing approaches.

Project Setup

  • Use a separate test project with naming convention [ProjectName].Tests
  • Reference Microsoft.NET.Test.Sdk, NUnit, and NUnit3TestAdapter packages
  • Create test classes that match the classes being tested (e.g., CalculatorTests for Calculator)
  • Use .NET SDK test commands: dotnet test for running tests

Test Structure

Installs
8.6K
GitHub Stars
35.0K
First Seen
Feb 25, 2026
csharp-nunit — github/awesome-copilot