Skip to content

Possible Bug - System.ArgumentException : The content root '' does not exist #7063

@rguthriemsft

Description

@rguthriemsft

I am seeing an issue when I try to create an integration test with a custom WebApplicationFactory. I get the error below but what is puzzling is the path is missing one folder in the path and I don't know where this value is coming from. It should be '/Users/richardguthrie/go/src/github.com/Azure-Samples/openhack-devops-team/apis/poi/tests/IntegrationTests'

The code is checked in at: https://github.com/Azure-Samples/openhack-devops-team/tree/unit_test3

Is this a bug or am I missing something when I try to init the webhost that would fix this? My intent is to spin up a server locally with in memory db to run the integration test. This happens when I run Debug Test from within VSCode using C# extension.

[xUnit.net 00:00:26.3698120] IntegrationTests.POIIntegrationTests.Get_EndpointsReturnSuccessAndCorrectContentType(url: "/api/poi/") [FAIL]
[xUnit.net 00:00:26.3715660] System.ArgumentException : The content root '/Users/richardguthrie/go/src/github.com/Azure-Samples/openhack-devops-team/apis/poi/IntegrationTests' does not exist.
[xUnit.net 00:00:26.3716860] Parameter name: contentRootPath
[xUnit.net 00:00:26.3732960] Stack Trace:
[xUnit.net 00:00:26.3754940] at Microsoft.AspNetCore.Hosting.Internal.HostingEnvironmentExtensions.Initialize(IHostingEnvironment hostingEnvironment, String contentRootPath, WebHostOptions options)
[xUnit.net 00:00:26.3756430] at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
[xUnit.net 00:00:26.3757000] at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
[xUnit.net 00:00:26.3758120] at Microsoft.AspNetCore.TestHost.TestServer..ctor(IWebHostBuilder builder, IFeatureCollection featureCollection)
[xUnit.net 00:00:26.3758790] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateServer(IWebHostBuilder builder) [xUnit.net 00:00:26.3760500] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.EnsureServer()
[xUnit.net 00:00:26.3761230] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateDefaultClient(DelegatingHandler[] handlers) [xUnit.net 00:00:26.3762400] at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory1.CreateClient

Metadata

Metadata

Assignees

No one assigned

    Labels

    Source - Docs.msDocs Customer feedback via GitHub Issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions