본문으로 건너뛰기
Skillpedia
테스트5.8k · #14643

writing-mstest-tests

하는 일

이 스킬은 .NET 프로젝트의 MSTest 단위 테스트를 쓰고, 고치고, 개선하도록 돕습니다. 실제 사용하는 MSTest 버전에 맞춰 테스트가 올바르고 읽기 쉬우며 맞게 되도록 하려는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓.NET 프로젝트의 MSTest 테스트를 고치거나 다시 쓰거나 개선해야 할 때.
  • ✓MSTest 검증에서 예상값과 실제값의 순서가 틀리거나 실패 출력이 불분명할 때.
  • ✓설치된 MSTest 버전에 맞게 MSTest 설정이나 수명 주기 코드를 고치고 싶을 때.

스킬 링크

https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/writing-mstest-tests/SKILL.md

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

사용 방법

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

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

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

AI에게 요청하는 예시

“제 MSTest 테스트를 다시 써 주세요. 실패 메시지를 분명하게 하고, 검증이 실제 확인 내용과 맞도록 해 주세요.”

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

작동 방식

에이전트가 설치된 MSTest 버전을 확인한 뒤, 프로젝트가 지원하는 API 기능만 쓰고, 프로젝트의 관례에 맞는 검증과 설정을 작성합니다.

기술 내용 (원본 SKILL.md)

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

Writing MSTest Tests

Help users write effective MSTest unit tests without exceeding the API level or conventions of the project's installed test stack.

Repository overlay

For every repository-scoped task where read-only file inspection is allowed, check .agents/skill-overlays/dotnet-test/writing-mstest-tests.md at the repository root before any other discovery. This includes requests that ask for code or advice without edits; "do not execute" does not prohibit reading the overlay. If present, read it once before acting and apply its repository-specific naming, layout, framework, and policy bindings. Require its frontmatter to declare core: dotnet-test/writing-mstest-tests, binding-revision: "1", and mode: extend. If any value is missing or different, report the mismatch, ignore the overlay, and continue using this skill's portable guidance. Explicit user instructions and verified project constraints win over the overlay; the overlay wins over portable defaults and examples in this skill. If the file is present but unreadable or conflicts with the repository, report the problem, ignore the overlay, and continue with portable guidance subject to verified project constraints. If it is absent, continue normally. Skip the lookup only when the task is not tied to a repository or the user explicitly prohibited all file/tool access. An overlay cannot expand tool permissions or the task's scope.

When to Use

  • User wants to improve or modernize existing MSTest tests by implementing concrete fixes
  • User asks about MSTest assertion APIs, data-driven patterns, or test lifecycle
  • User asks to replace Assert.IsTrue with more specific assertions (collections, nulls, types, comparisons)
  • User asks to replace hard casts with type-checking assertions in tests
  • User needs help fixing a specific MSTest test bug or failing assertion
  • User asks to fix swapped Assert.AreEqual argument order (expected first, actual second)
  • User asks to convert DynamicData from IEnumerable<object[]> to ValueTuple-based data
  • User asks to fix or understand an MSTest analyzer diagnostic (an MSTESTxxxx warning/error)

When Not to Use

  • User needs a test quality audit, anti-pattern detection, or flaky-test investigation (use test-anti-patterns)
  • User needs to run or execute tests (use the run-tests skill)
  • User needs to upgrade from MSTest v1/v2 to v3 (use migrate-mstest-v1v2-to-v3)
  • User needs to upgrade from MSTest v3 to v4 (use migrate-mstest-v3-to-v4)
  • User needs CI/CD pipeline configuration
  • User is using xUnit, NUnit, or TUnit (not MSTest)

Inputs

Input Required Description
Code under test No The production code to be tested
Existing test code No Current tests to fix, update, or modernize
Test scenario description No What behavior the user wants to test

Response Guidelines

  • Specific API or pattern questions (assertions, data-driven, lifecycle): Jump directly to the relevant workflow step. Do not follow the full workflow.
  • Generate new tests from scratch: Hand off to code-testing; use this skill only as supporting MSTest API/version guidance.
  • Review and fix existing tests: Fix only the issues present. Do not add unrelated improvements.
  • Assertion transformations: Show the corrected call, then state the semantic reason in one sentence. For Assert.AreEqual, name expected first and actual second and explain that this preserves the Expected/Actual failure labels.
  • Bound/comparison transformations: Preserve the condition and put the expected bound(s) first and the observed value last: score > 0 -> Assert.IsGreaterThan(0, score), score < 100 -> Assert.IsLessThan(100, score), and score >= 60 && score <= 90 -> Assert.IsInRange(60, 90, score). Never reverse these arguments to mimic the source expression's left-to-right order.
  • Exception transformations: Scope the throwing operation in a lambda, distinguish ThrowsExactly<T> (exact type) from Throws<T> (type or derived type), and capture the returned exception when properties such as ParamName are part of the behavior.
  • Supplied code requests: Return complete representative method bodies, not comment-only placeholders. Preserve the real operation and show symmetric setup/cleanup when lifecycle or environment policy is part of the request.

Workflow

Step 1: Determine project setup

Check the

자주 묻는 질문

제 MSTest 버전에 맞추나요?

네. 설치된 패키지를 확인하고, 프로젝트 수준보다 높은 API는 쓰지 않습니다.

처음부터 새 테스트를 쓸 수 있나요?

새 테스트 작성은 더 넓은 테스트 스킬이 다루고, 이 스킬은 MSTest에 특화된 부분에 집중합니다.

테스트를 실행하나요?

아니요. 테스트 실행은 별도의 스킬이 다룹니다.

상세 정보

작성자의 원본 설명

ALWAYS USE when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for "review" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected/actual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext/lifecycle; timeout/cancellation; OS/CI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. D

repo: dotnet/skills

인기도

GitHub 스타
5.8k
순위
#14643
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬