Search code examples
asp.net-coreintegration-testing

Differences between Microsoft.AspNetCore.Mvc.Testing and Microsoft.AspNetCore.TestHost packages


I have used several times the package Microsoft.AspNetCore.TestHost to host Asp.Net Core Web API applications in my integration test.

With Asp.Net Core 2.1 the package Microsoft.AspNetCore.Mvc.Testing was released. But Mvc.Testing has a dependency to TestHost.

I was wondering which features Mvc.Testing package is offering on top of the TestHost package. Specially when it is used in functional testing to host an API.


Solution

  • The Microsoft.AspNetCore.TestHost package consists of a set of types (including TestServer) to enable hosting your application in-memory for testing purposes. The Microsoft.AspNetCore.Mvc.Testing package provides infrastructure to enable functional testing of applications (including the TestServer) using the WebApplicationFactory class.

    Check out the docs for more info about integration/functional testing: https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests