I have set of selenium tests developed with VS 2017,Nunit (Project type - class library using .net framework 452. In my OneTimeSetUp, I am reading app.config that define few things such web URL, database connection string, Web Login user ID/password etc.
example:
<appSettings>
<add key="Browser" value="IExplorer" />
<add key="User" value="xxx" />
<add key="Password" value="xxx" />
<add key="BaseURL" value="http://ccc.com" />
<add key="DefaultImplicitDriverWait" value="15" />
<add key="TestRailIntegrationValue" value="False" />
<add key="GenerateCustomReport" value="False" />
</appSettings>
<connectionStrings>
<add name="DB1" connectionString="Data Source=db_name;Initial Catalog=db_instance;User Id=userid;Password=pwd;" />
</connectionStrings>
Then to run tests, I use nunit command line -- example
cd "C:\path-to-repo location"
packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console pathToDll --where "cat == Demo"
cmd /k
Now this works fine as long I target for one env. Now when I need to switch tests to different env, before running tests from command line or from VS 2017, I need to change the app.config
bu pointing to different env variables.
So is there a way, i can pass these values as parameter in the command line that then update the app.config
before executing any test?
If there any alternate solution/suggestion, I am happy to get all suggestion.