Categories
Agent Tooling (71)
- .agents/skills/agent-browser/references/authentication.md
- .agents/skills/agent-browser/references/commands.md
- .agents/skills/agent-browser/references/profiling.md
- .agents/skills/agent-browser/references/proxy-support.md
- .agents/skills/agent-browser/references/session-management.md
- .agents/skills/agent-browser/references/snapshot-refs.md
- .agents/skills/agent-browser/references/video-recording.md
- .agents/skills/agent-browser/SKILL.md
- .agents/skills/aspire-deployment/references/aws.md
- .agents/skills/aspire-deployment/references/azure.md
- .agents/skills/aspire-deployment/references/cicd.md
- .agents/skills/aspire-deployment/references/docker-compose.md
- .agents/skills/aspire-deployment/references/javascript.md
- .agents/skills/aspire-deployment/references/kubernetes.md
- .agents/skills/aspire-deployment/references/preflight.md
- .agents/skills/aspire-deployment/SKILL.md
- .agents/skills/aspire-monitoring/references/diagnostics-bridge.md
- .agents/skills/aspire-monitoring/references/monitoring.md
- .agents/skills/aspire-monitoring/references/playwright-handoff.md
- .agents/skills/aspire-monitoring/SKILL.md
- .agents/skills/aspire-orchestration/references/agent-workflows.md
- .agents/skills/aspire-orchestration/references/app-commands.md
- .agents/skills/aspire-orchestration/references/detection.md
- .agents/skills/aspire-orchestration/references/resource-management.md
- .agents/skills/aspire-orchestration/references/safety-guardrails.md
- .agents/skills/aspire-orchestration/SKILL.md
- .agents/skills/aspire/references/aspire-13-3-breaking-changes.md
- .agents/skills/aspire/SKILL.md
- .agents/skills/aspireify/references/apphost-wiring.md
- .agents/skills/aspireify/references/csharp-authoring.md
- .agents/skills/aspireify/references/docker-compose.md
- .agents/skills/aspireify/references/full-solution-apphosts.md
- .agents/skills/aspireify/references/javascript-apps.md
- .agents/skills/aspireify/references/opentelemetry.md
- .agents/skills/aspireify/references/scan-and-propose.md
- .agents/skills/aspireify/references/service-defaults.md
- .agents/skills/aspireify/references/typescript-authoring.md
- .agents/skills/aspireify/references/validation.md
- .agents/skills/aspireify/SKILL.md
- .agents/skills/caveman-compress/README.md
- .agents/skills/caveman-compress/SECURITY.md
- .agents/skills/caveman-compress/SKILL.md
- .agents/skills/caveman-help/README.md
- .agents/skills/caveman-help/SKILL.md
- .agents/skills/caveman-stats/README.md
- .agents/skills/caveman-stats/SKILL.md
- .agents/skills/caveman/README.md
- .agents/skills/caveman/SKILL.md
- .agents/skills/csharp-developer/SKILL.md
- .agents/skills/dotnet-inspect/SKILL.md
- .agents/skills/efcore-data-layer/SKILL.md
- .agents/skills/git/SKILL.md
- .agents/skills/microsoft-code-reference/SKILL.md
- .agents/skills/microsoft-docs/SKILL.md
- .agents/skills/microsoft-skill-creator/references/skill-templates.md
- .agents/skills/microsoft-skill-creator/SKILL.md
- .agents/skills/skill-creator/references/output-patterns.md
- .agents/skills/skill-creator/references/workflows.md
- .agents/skills/skill-creator/SKILL.md
- .agents/skills/tunit-testing/references/aspire-integration.md
- .agents/skills/tunit-testing/references/aspnetcore-integration.md
- .agents/skills/tunit-testing/references/assertions.md
- .agents/skills/tunit-testing/references/data-driven.md
- .agents/skills/tunit-testing/references/infrastructure-and-troubleshooting.md
- .agents/skills/tunit-testing/references/lifecycle-hooks.md
- .agents/skills/tunit-testing/SKILL.md
- AGENTS.md
- backend/AGENTS.md
- backend/tests/AGENTS.md
- Front/AGENT.md
- opencode.jsonc
ASP.NET Core Integration
Use these patterns for ASP.NET Core integration tests built on TUnit.AspNetCore.
Prefer TUnit's ASP.NET Base Types
- Derive factories from
TestWebApplicationFactory<TEntryPoint>, not directly fromWebApplicationFactory<TEntryPoint>. - Derive test bases from
WebApplicationTest<TFactory, TEntryPoint>. - This preserves TUnit tracing, per-test logging correlation, and test context propagation.
public sealed class AppFactory : TestWebApplicationFactory<Program>
{
}
public abstract class TestsBase : WebApplicationTest<AppFactory, Program>
{
}Factory vs Test Responsibilities
Use the factory for shared defaults that apply to every test in the class/session:
- shared environment selection
- shared service replacement defaults
- shared startup-time configuration defaults
Use the WebApplicationTest overrides for per-test behavior:
SetupAsync()for async preparation before factory creationConfigureTestConfiguration(...)for per-test configuration overridesConfigureTestServices(...)for per-test DI overridesConfigureWebHostBuilder(...)only as an escape hatch
Configuration Timing Matters
If configuration must be visible while Program.cs is building the app, put it in:
TestWebApplicationFactory.ConfigureStartupConfiguration(...)
Do not rely on ConfigureWebHost(...).ConfigureAppConfiguration(...) for settings that must exist during application startup. That path is too late for some startup reads.
public sealed class AppFactory : TestWebApplicationFactory<Program>
{
protected override void ConfigureStartupConfiguration(IConfigurationBuilder configurationBuilder)
{
configurationBuilder.AddInMemoryCollection(new Dictionary<string, string?>
{
["Feature:Enabled"] = bool.TrueString,
});
}
}For per-test values discovered in SetupAsync(), use ConfigureTestConfiguration(...):
public abstract class TestsBase : WebApplicationTest<AppFactory, Program>
{
protected string SchemaName { get; private set; } = null!;
protected override async Task SetupAsync()
{
SchemaName = GetIsolatedName("schema");
await CreateSchemaAsync(SchemaName);
}
protected override void ConfigureTestConfiguration(IConfigurationBuilder config)
{
config.AddInMemoryCollection(new Dictionary<string, string?>
{
["Database:Schema"] = SchemaName,
});
}
}Per-Test Isolation
For shared mutable resources, isolate by test.
- use
GetIsolatedName("...")for tables, schemas, queues, topics - use
GetIsolatedPrefix()for cache keys, blob prefixes, Redis keys
For EF Core schema isolation, prefer:
SchemaName = GetIsolatedName("schema")- creating the schema in
SetupAsync() IModelCacheKeyFactorykeyed by schema- dropping the schema in
[After(Test)]
Using the Factory in Tests
Factory is a per-test TracedWebApplicationFactory<TEntryPoint>.
Use:
Factory.CreateClient()for normal requestsFactory.Servicesfor resolving services scoped to the isolated test factory
If you need advanced WebApplicationFactory APIs such as WithWebHostBuilder(...), go through Factory.Inner:
await using var customFactory = new TracedWebApplicationFactory<Program>(
Factory.Inner.WithWebHostBuilder(builder =>
{
builder.UseSetting("Feature:Enabled", bool.FalseString);
}));
var client = customFactory.CreateClient();Service Replacement
When overriding app services in tests, remove or replace existing registrations instead of stacking duplicates.
protected override void ConfigureTestServices(IServiceCollection services)
{
services.ReplaceService<IEmailSender>(new FakeEmailSender());
}Cancellation
Prefer injecting CancellationToken into test methods and hooks.
For code inside WebApplicationTest, use the current test execution token if needed:
protected CancellationToken CancellationToken => TestContext.Current!.Execution.CancellationToken;