WebApplicationFactory throws error that contentRootPath does not exist in ASP.NET Core integration test

后端 未结 6 1234
醉梦人生
醉梦人生 2021-02-13 18:52

I have a ASP.NET Core project with some simple Razor pages and a Web API controller.

I\'m using Clean Architecture as a starting point. I\'ve renamed the project names,

6条回答
  •  旧巷少年郎
    2021-02-13 19:51

    It seems that WebApplicationFactory should use the real Startup class as the type of argument:

    class TestWebApplicationFactory : WebApplicationFactory
    {
         protected override IWebHostBuilder CreateWebHostBuilder()
         {
             return WebHost.CreateDefaultBuilder();
         }
    }
    

    Note that Startup is the type on true SUT code and TestableStartup is the TestingStartup configuration.

提交回复
热议问题