csharp-nunit
Skill1 starsChanged 9 months agoMITView on GitHub
Get best practices for NUnit unit testing, including data-driven tests
2 other projects use a version of this.
Adopted by
Most recently taken up by
- glennawatson/CSharpAgentSkillstheir own version, first seen Oct 1, 2026
- github/awesome-copilotword for word, first seen Sep 23, 2026
Other versions2 projects use a version of this.
Word for word · 1
- github/awesome-copilot★ 40k100% same
Edited · 0
None found.
Wrote their own version · 1
- glennawatson/CSharpAgentSkills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository28 other files it gives its agents.
- aspireSkill
- brainstormingSkill
- create-github-issue-feature-from-specificationSkill
- create-github-issues-feature-from-implementation-planSkill
- create-implementation-planSkill
- create-specificationSkill
- csharp-asyncSkill
- csharp-docsSkill
- csharp-mcp-server-generatorSkill
- csharp-mstestSkill
- csharp-tunitSkill
- csharp-xunitSkill
- dispatching-parallel-agentsSkill
- dotnet-best-practicesSkill
- dotnet-design-pattern-reviewSkill
- dotnet-upgradeSkill
- editorconfigSkill
- ef-coreSkill
- executing-plansSkill
- finishing-a-development-branchSkill
- receiving-code-reviewSkill
- requesting-code-reviewSkill
- skill-creatorSkill
- update-packagesSkill
- using-superpowersSkill
- verification-before-completionSkill
- writing-plansSkill
- writing-skillsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
34 rules. About 0 are common, 8 are distinctive, and 26 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
26
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use a separate test project with naming convention [ProjectName].Tests
- Very specific: line 14
Create test classes that match the classes being tested (e.g., CalculatorTests for Calculator)
- Very specific: line 15
Use .NET SDK test commands: dotnet test for running tests
- Very specific: line 20
Use [Test] attribute for test methods
- Distinctive: line 21
Follow the Arrange-Act-Assert (AAA) pattern
- Very specific: line 23
Use [SetUp] and [TearDown] for per-test setup and teardown
- Very specific: line 24
Use [OneTimeSetUp] and [OneTimeTearDown] for per-class setup and teardown
- Very specific: line 25
Use [SetUpFixture] for assembly-level setup and teardown
- Distinctive: line 29
Keep tests focused on a single behavior
- Distinctive: line 30
Avoid testing multiple behaviors in one test method
- Distinctive: line 31
Use clear assertions that express intent
- Very specific: line 38
Use [TestCase] for inline test data
- Very specific: line 39
Use [TestCaseSource] for programmatically generated test data
- Very specific: line 40
Use [Values] for simple parameter combinations
- Very specific: line 41
Use [ValueSource] for property or method-based data sources
- Very specific: line 42
Use [Random] for random numeric test values
- Very specific: line 43
Use [Range] for sequential numeric test values
- Very specific: line 44
Use [Combinatorial] or [Pairwise] for combining multiple parameters
- Very specific: line 48
Use Assert.That with constraint model (preferred NUnit style)
- Very specific: line 49
Use constraints like Is.EqualTo, Is.SameAs, Contains.Item
- Very specific: line 50
Use Assert.AreEqual for simple value equality (classic style)
- Very specific: line 51
Use CollectionAssert for collection comparisons
- Very specific: line 52
Use StringAssert for string-specific assertions
- Very specific: line 53
Use Assert.Throws<T> or Assert.ThrowsAsync<T> to test exceptions
- Distinctive: line 54
Use descriptive messages in assertions for clarity on failure
- Distinctive: line 58
Consider using Moq or NSubstitute alongside NUnit
- Distinctive: line 60
Use interfaces to facilitate mocking
- Distinctive: line 61
Consider using a DI container for complex test setups
- Very specific: line 66
Use categories with [Category("CategoryName")]
- Very specific: line 67
Use [Order] to control test execution order when necessary
- Very specific: line 68
Use [Author("DeveloperName")] to indicate ownership
- Very specific: line 69
Use [Description] to provide additional test information
- Very specific: line 70
Consider [Explicit] for tests that shouldn't run automatically
- Very specific: line 71
Use [Ignore("Reason")] to temporarily skip tests
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.,
CalculatorTestsforCalculator) - Use .NET SDK test commands:
dotnet testfor running tests
Test Structure
- Apply
[TestFixture]attribute to test classes - Use
[Test]attribute for test methods - Follow the Arrange-Act-Assert (AAA) pattern
- Name tests using the pattern
MethodName_Scenario_ExpectedBehavior - Use
[SetUp]and[TearDown]for per-test setup and teardown - Use
[OneTimeSetUp]and[OneTimeTearDown]for per-class setup and teardown - Use
[SetUpFixture]for assembly-level setup and teardown
Standard Tests
- Keep tests focused on a single behavior
- Avoid testing multiple behaviors in one test method
- Use clear assertions that express intent
- Include only the assertions needed to verify the test case
- Make tests independent and idempotent (can run in any order)
- Avoid test interdependencies
Data-Driven Tests
- Use
[TestCase]for inline test data - Use
[TestCaseSource]for programmatically generated test data - Use
[Values]for simple parameter combinations - Use
[ValueSource]for property or method-based data sources - Use
[Random]for random numeric test values - Use
[Range]for sequential numeric test values - Use
[Combinatorial]or[Pairwise]for combining multiple parameters
Assertions
- Use
Assert.Thatwith constraint model (preferred NUnit style) - Use constraints like
Is.EqualTo,Is.SameAs,Contains.Item - Use
Assert.AreEqualfor simple value equality (classic style) - Use
CollectionAssertfor collection comparisons - Use
StringAssertfor string-specific assertions - Use
Assert.Throws<T>orAssert.ThrowsAsync<T>to test exceptions - Use descriptive messages in assertions for clarity on failure
Mocking and Isolation
- Consider using Moq or NSubstitute alongside NUnit
- Mock dependencies to isolate units under test
- Use interfaces to facilitate mocking
- Consider using a DI container for complex test setups
Test Organization
- Group tests by feature or component
- Use categories with
[Category("CategoryName")] - Use
[Order]to control test execution order when necessary - Use
[Author("DeveloperName")]to indicate ownership - Use
[Description]to provide additional test information - Consider
[Explicit]for tests that shouldn't run automatically - Use
[Ignore("Reason")]to temporarily skip tests
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

