dotnet / dotnet/aspnetcore

Possible bug in WebApplicationFactory->WithWebHostBuilder

Open
#34,277 7 comments 1 reaction 0 assignees View on GitHub
area-mvc investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

I'm using Microsoft.AspNetCore.Mvc.Testing 3.1.12 but I can see that current version have same functionality.
When we are creating child builder

https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs#L117

we also save it to dispose

https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs#L136

but if we operate on returned WebApplicationFactory that is DelegatedWebApplicationFactory inside and create another child

https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs#L639

there is no code that add it to dispose so it is disposed some time later. This have some implication and sometimes unexpected behaviors depending where we execute our test (VS vs Rider vs dotnet test - timeout of this dispose is diffrent)

Is this planned behavior or bug?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.