Hi,
First of all, it's awesome that NCrunch even has support in handling the ContentRoot for ASP.NET Core integration tests, however, I encountered a bug there. I've reproduced the issue in this repo:
https://github.com/tiesm...er/ReproduceNCrunchBug.
Steps to reproduce:
1. Create a new ASP.NET Core MVC application (ae9ea87)
2. Add integration tests, as described here:
https://docs.microsoft.c...-core-integration-tests (97ad82b)
3. Override the assembly name for the main project (064fbb5)
Expected result:UnitTest1.Test1 still creates the test server successfully
Actual result:Exception in WebHostBuilderExtensions.UseSolutionRelativeContentRoot()
System.InvalidOperationException: Solution root could not be located using application root C:\Users\ties\AppData\Local\NCrunch\18800\13\ReproduceNCrunchBug.IntegrationTests\bin\Debug\netcoreapp2.2\.
at Microsoft.AspNetCore.TestHost.WebHostBuilderExtensions.UseSolutionRelativeContentRoot(IWebHostBuilder builder, String solutionRelativePath, String applicationBasePath, String solutionName)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.SetContentRoot(IWebHostBuilder builder)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer()
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)
at ReproduceNCrunchBug.IntegrationTests.UnitTest1.Test1() in C:\src\playground\ReproduceNCrunchBug\ReproduceNCrunchBug.IntegrationTests\UnitTest1.cs:line 14
Cause:NCrunch sets the environment variable ASPNETCORE_TEST_CONTENTROOT_<APPNAME> in order for WebApplicationFactory to find the appropriate content root that belongs to the Startup class (https://github.com/aspnet/AspNetCore/blob/7e3c69eae0cc634e37778c4d55b19fc7c1c432db/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs#L207-L223). However, it searches using the Startup's assembly name, while NCrunch adds the ASPNETCORE_TEST_CONTENTROOT_<APPNAME> environment variables based on the project names. This results in the bug.
@remco
I hope this is enough to reproduce the bug. Let me know if you need more for this.