roninforge/roninforge-aspnet/aspnet-testing-setup
Claude Code and agent skill by roninforge/roninforge-aspnet
- community
Checking that the SKILL.md file is still in the repository.
Wire up an xUnit + WebApplicationFactory + Testcontainers test project for ASP.NET Core 9. Covers Postgres/Redis containers, ConfigureTestServices to swap dependencies, MockHttpMessageHandler for typed HttpClient, FluentAssertions for readable tests.
Install
npx vskill@latest install roninforge/roninforge-aspnet/aspnet-testing-setupSKILL.md
The same SKILL.md was published earlier as roninforge/roninforge-aspnet/aspnet-testing-setup.
Set up ASP.NET Core 9 Testing
When to Use
When adding integration tests to a new or existing ASP.NET Core 9 project, or replacing brittle unit tests with in-process integration via WebApplicationFactory.
Instructions
Step 1: Create the test project
Add packages:
Step 2: Expose Program as a partial class
In Program.cs, add at the very bottom:
Without this, WebApplicationFactory<Program> cannot find a TEntryPoint because top-level Program.cs makes the type internal.
Step 3: Database fixture with Testcontainers
The collection definition makes the fixture singleton across all classes that opt in via [Collection(nameof(IntegrationTests))].
Step 4: Custom WebApplicationFactory
The factory inherits the real Program.cs configuration and overrides only what the tests need.
Step 5: First test
Step 6: Mocking outbound HTTP
For a typed client (PaymentClient) you can swap the underlying HttpMessageHandler:
Step 7: Async assertions and lifecycle
xUnit conventions:
[Fact]for parameterless tests,[Theory]+[InlineData]for table-driven.- Test methods return
Taskand are awaited internally. - AAA (Arrange, Act, Assert) with blank lines between sections.
- One logical assertion per test (a fluent chain counts as one).
Step 8: CI considerations
Pin container image tags in CI (postgres:16-alpine, not postgres). Pre-pull images at the start of the workflow to amortize startup:
Anti-patterns to avoid
Microsoft.EntityFrameworkCore.InMemoryfor tests that simulate Postgres - SQL dialect mismatches hide real bugs. Use Testcontainers.- Mocking
DbContext. Always use a real database (Testcontainers). - One container per test class without
IClassFixture/ICollectionFixture- each test class starts a new container, which is slow. Thread.Sleepin async tests. UseTask.Delay(_, ct)or await whatever you are waiting for.- Skipping
DatabaseMigrateAsync()in test setup - the schema does not exist on a fresh container.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/aspnet-testing-setup/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/roninforge/roninforge-aspnet/aspnet-testing-setup)