Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Bug in setting ASPNETCORE_TEST_CONTENTROOT_ by NCrunch
tiesmaster
#1 Posted : Thursday, April 18, 2019 1:50:44 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/18/2019(UTC)
Posts: 3
Location: Netherlands

Was thanked: 1 time(s) in 1 post(s)
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.
Remco
#2 Posted : Thursday, April 18, 2019 11:10:47 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,646

Thanks: 734 times
Was thanked: 936 time(s) in 892 post(s)
Hi, thanks for sharing this issue.

Can you confirm which version of NCrunch you're running? I vaguely remember this issue being reported before and I thought we'd fixed it.
tiesmaster
#3 Posted : Friday, April 19, 2019 8:48:19 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/18/2019(UTC)
Posts: 3
Location: Netherlands

Was thanked: 1 time(s) in 1 post(s)
Ey, thanks for the swift reply. I was running second-to-last version (v3.25.0.something), but just updated to latest (v3.26.0.4) and the tests in the reproduction still fails.
Remco
#4 Posted : Saturday, April 20, 2019 1:00:45 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,646

Thanks: 734 times
Was thanked: 936 time(s) in 892 post(s)
tiesmaster
#5 Posted : Saturday, April 20, 2019 7:19:17 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/18/2019(UTC)
Posts: 3
Location: Netherlands

Was thanked: 1 time(s) in 1 post(s)
Awesome! That fixes it 👍

Thanks 😎!!
1 user thanked tiesmaster for this useful post.
Remco on 4/20/2019(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.042 seconds.