Prompt file imported from sextondjc/agentic (
.github/prompts/execute-testing-xunit.prompt.md). Copyright stays with the author.
XUnit Testing Prompt
Route this request to orchestrator.
Use the test-driven-development skill as the primary workflow.
Generate tests named {Scenario}{ExpectedBehavior} using xUnit and Moq, aligned with workspace rules.
Project Setup
- Use a separate test project named
[ProjectName].[TestProjectType].Tests. - Use
Microsoft.NET.Test.Sdk,xunit, andxunit.runner.visualstudio. - Keep test folders and organization aligned with the production code under test.
Test Structure
- Use
[Fact]for simple tests and[Theory]for data-driven tests. - Follow the AAA pattern without adding Arrange/Act/Assert comments.
- Keep tests focused on one behavior.
- Make tests independent, repeatable, and safe to run in any order.
- Use constructor setup,
IDisposable,IClassFixture<T>, orICollectionFixture<T>where appropriate.
Assertions and Exceptions
- Assert with xUnit only.
- Use
Assert.Equal,Assert.True,Assert.False,Assert.Contains, and other xUnit assertions as appropriate. - Use
Assert.Throws<T>andAssert.ThrowsAsync<T>for exception behavior. - FluentAssertions is banned.
Mocking
- Use Moq for external dependencies only.
- Prefer testing through public APIs.
- Avoid mocking code that is part of the solution under test.
Coverage Focus
- Test changed behavior and edge cases.
- Ensure guard failures are covered.
- Prefer tests that validate business behavior over internal implementation detail.
Output Contract
Return output in this order:
- Proposed test inventory by target type/member.
- Generated test code.
- Test project/package assumptions.
- Gaps blocked by missing production context.