ワンクリックで
write-unit-tests
Write comprehensive unit tests with proper setup, assertions, and coverage of happy paths, edge cases, and error scenarios
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Write comprehensive unit tests with proper setup, assertions, and coverage of happy paths, edge cases, and error scenarios
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Show a comprehensive project status dashboard: task queue, blocked items, session state, verification, and git status.
Run all verification gates (privacy scan, git cleanliness, git pushed) and report results.
Generate a QA/UAT test plan from product specifications and task definitions, covering acceptance testing, integration flows, and exploratory testing. Unit tests are out of scope (handled by write-unit-tests skill).
| name | write-unit-tests |
| description | Write comprehensive unit tests with proper setup, assertions, and coverage of happy paths, edge cases, and error scenarios |
| auto_invoke | true |
Guide for writing effective unit tests that verify behavior and catch regressions.
[Fact]
public void MethodName_Scenario_ExpectedBehavior()
{
// Arrange - Set up test data and dependencies
var dependency = Substitute.For<IDependency>();
dependency.GetData().Returns(expectedData);
var sut = new SystemUnderTest(dependency);
// Act - Execute the behavior being tested
var result = sut.MethodUnderTest(input);
// Assert - Verify expected outcomes
result.Should().Be(expectedValue);
dependency.Received(1).GetData();
}
Use descriptive names that explain what's being tested:
MethodName_Scenario_ExpectedBehaviorMethodName_WhenCondition_ShouldDoSomethingMethodName_GivenInput_ReturnsExpectedOutputExamples:
Calculate_WithNegativeNumber_ThrowsArgumentExceptionProcessOrder_WhenInventoryInsufficient_ReturnsFailureResultFormatDate_GivenNull_ReturnsEmptyString// Good - Mock interface
var repository = Substitute.For<IRepository>();
// Bad - Don't mock concrete classes or value objects
var dto = Substitute.For<DataTransferObject>(); // ❌
Use fluent assertions for clarity:
// Good - Fluent and readable
result.Should().Be(expected);
result.Should().BeEquivalentTo(expected);
collection.Should().HaveCount(3);
action.Should().Throw<ArgumentException>()
.WithMessage("*invalid*");
// Avoid - Less clear
Assert.Equal(expected, result);
Assert.True(result != null);
[Fact]
public void Method_InvalidInput_ThrowsException()
{
var sut = new SystemUnderTest();
var action = () => sut.Method(invalidInput);
action.Should().Throw<ArgumentException>()
.WithMessage("*parameter*");
}
[Fact]
public async Task MethodAsync_Scenario_ExpectedBehavior()
{
var sut = new SystemUnderTest();
var result = await sut.MethodAsync();
result.Should().NotBeNull();
}
[Theory]
[InlineData(0, 0)]
[InlineData(1, 1)]
[InlineData(-1, 1)]
public void Abs_VariousInputs_ReturnsAbsoluteValue(int input, int expected)
{
var result = Math.Abs(input);
result.Should().Be(expected);
}
Tests/
├── Unit/
│ ├── Services/
│ │ └── OrderServiceTests.cs
│ ├── Handlers/
│ │ └── CreateOrderHandlerTests.cs
│ └── Validators/
│ └── OrderValidatorTests.cs