1
votes

I am writing a system integration test project for one of our more complex backend systems. To conform to company stacks, the test solution is using .net core 2.1 and nunit 3 with c#. It has a testconfiguration.cs file which gets test config values from appsettings.json using iconfiguration classes. The appsettings.json has configuration like serviceconnectionstring s etc.
The company uses azure devops as the CI/CD tool. I set up a build pipeline to build the solution and publish the artifact to be consumed on a release pipeline. This release pipline has 2 stages (i.e.: 2 diff environment) . And the appsetting values come from the pipeline variables. I have only ever deployed an actual service api app before using the azure app services deployment task where i can set the app settings config on the release pipeline task. But when it comes to standalone test solution like nunit which i dont really need to 'deploy' , how can i set the appsettings for the test solution at runtime and run tests? I was googling along these terms and so many articles talk only about the vstest run tasks to run tests but it doesnt really allow any appsettings.json to be updated per runtime. How should I handled this? Some environment, i would have no idea what the dbconnectionstring would be, these values are controlled by ops on the pipelines so I am trying to find a way that the test solution can consume it agnostically.

1

1 Answers

1
votes

According to your description, seems you want to override the settings which defined in the appsettings.json before running the integration tests.

If so, you can try to install the Replace Tokens extension, then use Replace Tokens task to load and change the settings defined in the appsettings.json file.

You can also transform the settings or use File Creator to create a new appsettings.jsonfile to overwrite the existing one.

Below blogs for your reference: