AppSettings.json for Integration Test in ASP.NET Core

后端 未结 3 1136
花落未央
花落未央 2020-12-10 01:46

I am following this guide. I have a Startup in the API project that uses an appsettings.json configuration file.

public class Startu         


        
3条回答
  •  粉色の甜心
    2020-12-10 02:22

    In the end, I followed this guide, specifically the Integration Testing section towards the bottom of the page. This removes the need to copy the appsettings.json file to the output directory. Instead it tells the test project the actual directory of the web application.

    As for copying the appsettings.json to the output directory, I also managed to get that to work. Combined with the answer from dudu, I used include instead of includeFiles so the resulting section would look something like this:

    "buildOptions": {
        "copyToOutput": {
            "include": "appsettings.json"
        }
    }
    

    I'm not entirely sure why this works but it does. I had a quick look at the documentation but couldn't find any real differences and since the original problem was essentially solved I didn't look further.

提交回复
热议问题