dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.23k stars 9.95k forks source link

Unit tests error on ubuntu for simple dotnet 5 web api tests application #33427

Open SemShekhovtsovIntellias opened 3 years ago

SemShekhovtsovIntellias commented 3 years ago

Describe the bug

When executing unit tests for web API project on ubuntu 20.04 (latest) it throws exception that the solution root could not be located using application root.

If the same published unit tests project run on the windows platform, then all tests pass without any error. It works as expected.

To Reproduce

Sample project on GitHub: https://github.com/SamShekhovtsov/webapitests 1) Create simple Web API project and Unit Tests project that test the web API. 2) Publish unit tests project to a folder. 3) create a simple docker container using latest ubuntu image and copy 'publish' folder content into the container 'app' directory 4) install power shell and dotnet 5 on the ubuntu:latest container 5) run unit tests using power shell: dotnet test WebAPIProject1.Tests.dll

Exceptions (if any)

Failed Get_Success [104 ms] Error Message: Unable to create instance of class WebAPIProject1.Tests.WeatherForecastControllerTest. Error: System.InvalidOperationException: Solution root could not be located using application root /app/.. Stack Trace: at Microsoft.AspNetCore.TestHost.WebHostBuilderExtensions.UseSolutionRelativeContentRoot(IWebHostBuilder builder, String solutionRelativePath, String applicationBasePath, String solutionName) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.SetContentRoot(IWebHostBuilder builder) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.b__20_0(IWebHostBuilder webHostBuilder) at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action1 configure, Action1 configureWebHostBuilder) at Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions.ConfigureWebHost(IHostBuilder builder, Action1 configure) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.EnsureServer() at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateDefaultClient(DelegatingHandler[] handlers) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateClient(WebApplicationFactoryClientOptions options) at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateClient() at WebAPIProject1.Tests.WeatherForecastControllerTest..ctor() in C:\Projects\APIProjectWithUnitTests\WebAPIProject1.Tests\WeatherForecastControllerTest.cs:line 38

Further technical details

PS /app> dotnet --info .NET SDK (reflecting any global.json): Version: 5.0.301 Commit: cc8c0abb32

Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.301/

Host (useful for support): Version: 5.0.7 Commit: 556582d964

.NET SDKs installed: 5.0.301 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.7 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.7 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download PS /app>

ghost commented 3 years ago

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

mkArtakMSFT commented 3 years ago

@javiercn what do you think we should do here?

ghost commented 2 years ago

Thanks for contacting us. We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost commented 1 year ago

Thanks for contacting us. We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.