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

后端 未结 6 1250
醉梦人生
醉梦人生 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:45

    I have a really simple project structure and ran into the same issue. Project structure:

    -repo_root
     - myProject
       - myProject.csproj
       - src
     - myProjectTest
       - myProjectTest.csproj
       - tests
    

    All of the above answers didn't work for me. I went throught the docs and other sources related to the WebApplicationFactoryContentRootAttribute to no avail. I also looked into the WebApplicationFactory implementation and tried to use the TEST_CONTENTROOT_APPNAME in settings to no avail.

    What did help in the end was creating an empty myProject.sln file in the repo_root.

提交回复
热议问题