Integration tests for ASP.NET Core APIs — WebApplicationFactory, xUnit, ConfigureTestServices, FluentAssertions, database isolation
97
96%
Does it follow best practices?
Impact
99%
1.45xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent correctly sets up a new ASP.NET Core integration test project using xUnit and WebApplicationFactory. Evaluates proper package choices, Program class exposure, WebApplicationFactory subclassing with ConfigureTestServices, database isolation, and environment configuration.",
"type": "weighted_checklist",
"checklist": [
{
"name": "xUnit project in tests/",
"description": "Test project is created using `dotnet new xunit` (not nunit or mstest) and placed in a `tests/` folder",
"max_score": 8
},
{
"name": "Mvc.Testing package",
"description": "Microsoft.AspNetCore.Mvc.Testing package is added to the test project",
"max_score": 8
},
{
"name": "InMemory package",
"description": "Microsoft.EntityFrameworkCore.InMemory package is added to the test project",
"max_score": 8
},
{
"name": "FluentAssertions package",
"description": "FluentAssertions package is added to the test project",
"max_score": 8
},
{
"name": "Program class exposed",
"description": "The API project (not the test project) contains `public partial class Program { }` to expose Program to WebApplicationFactory",
"max_score": 10
},
{
"name": "Custom factory subclass",
"description": "A custom class extends WebApplicationFactory<Program> rather than using the base class directly",
"max_score": 8
},
{
"name": "ConfigureTestServices used",
"description": "The factory uses `ConfigureTestServices` (not `ConfigureServices`) inside `ConfigureWebHost`",
"max_score": 10
},
{
"name": "DbContext descriptor removed",
"description": "The real DbContext descriptor is removed via `SingleOrDefault` / `services.Remove` before adding the test database",
"max_score": 10
},
{
"name": "Guid.NewGuid() database name",
"description": "InMemoryDatabase is configured with a unique name using `Guid.NewGuid()` (e.g. `\"TestDb_\" + Guid.NewGuid()`)",
"max_score": 10
},
{
"name": "UseEnvironment Testing",
"description": "The factory calls `builder.UseEnvironment(\"Testing\")`",
"max_score": 10
},
{
"name": "IClassFixture on test class",
"description": "The test class implements `IClassFixture<CustomWebApplicationFactory>` (or equivalent factory name)",
"max_score": 10
}
]
}