본문으로 건너뛰기
Skillpedia
테스트40k · #7154

csharp-nunit

하는 일

이 도구는 NUnit을 사용해 코드의 효율적인 테스트를 작성하도록 돕습니다. 일반 테스트와 다양한 데이터를 사용하는 테스트 모두에 대한 모범 사례를 가르칩니다.

사용하는 경우

  • ✓코드가 올바르게 작동하는지 확인하고 싶을 때.
  • ✓많은 다른 데이터 입력이 필요한 테스트를 만들 때.
  • ✓테스트를 체계적이고 표준화되게 정리하고 싶을 때.

스킬 링크

https://github.com/github/awesome-copilot/blob/main/skills/csharp-nunit/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/csharp-nunit/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“2 + 2 = 4인지 확인하는 덧셈 함수 테스트를 어떻게 작성하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 테스트 파일을 어떻게 정리할지, 테스트에 명확한 이름을 어떻게 붙일지, 테스트를 설정하고 실행하는 특별한 속성(attribute)을 어떻게 사용할지 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

  • 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.That with constraint model (preferred NUnit style)
  • Use constraints like Is.EqualTo, Is.SameAs, Contains.Item
  • Use Assert.AreEqual for simple value equality (classic style)
  • Use CollectionAssert for collection comparisons
  • Use StringAssert for string-specific assertions
  • Use Assert.Throws<T> or Assert.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
자주 묻는 질문

단위 테스트란 무엇인가요?

코드의 특정 부분(함수나 메서드)이 기대대로 작동하는지 확인하는 작은 테스트입니다.

NUnit이란 무엇인가요?

C#에서 테스트를 작성하기 위한 인기 있는 라이브러리입니다.

‘데이터 기반’ 테스트란 무엇인가요?

같은 테스트를 반복해서 작성하지 않고도 서로 다른 데이터 집합으로 여러 번 실행되는 테스트입니다.

상세 정보

작성자의 원본 설명

Get best practices for NUnit unit testing, including data-driven tests

repo: github/awesome-copilot

인기도

GitHub 스타
40k
순위
#7154
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬