autofac/Examples

Generic Host no longer calls ConfigureTestContainer for container overrides

ssunkari opened this issue · 1 comments

I have Integration tests, which uses WebApplicationFactory net core interface.
Earlier netcore versions <3.0 has a way to override custom container registrations but once switched to generic host startup mode. The method override ConfigureTestContainer no longer get called. What do you recommend in terms of overriding the registrations in Autofac container for unit testing.

Below mehod is not called anymore in net core 3.

 .ConfigureTestContainer<ContainerBuilder>(containerBuilder =>
            { }

The order in which application bootstrap for IntegrationTests are:
Startup -> ConfigureServices
TestStartup -> ConfigureServices (Method Override if defined)
TestStartup -> ConfigureTestServices
Startup -> ConfigureContainer
TestStartup -> ConfigureTestContainer (Not called since netcore 3.0 upgrade with generic host usage)

There is a github issue on dotnet github page dotnet/aspnetcore#14907
but cannot find the solution.