Skip to content

Update App.config or appsettings.json file before test execution

Jakub Raczek edited this page Nov 21, 2021 · 1 revision

You can use PowerShell set_AppConfig_for_tests.ps1 script for updating App.config or appsettings.json file before test execution. Script can be found in folder "\scripts" set_AppConfig_for_tests.ps1

Parameters:

  • OutDir: Working directory.
  • onfigName: Name of config file for update.
  • section: Name of section in config file for update.
  • keys: Names of keys for update separated by |.
  • values:Values of keys for update separated by |, in same order as keys.
  • logValues: By default displaying values of keys in logs is disabled. Set it to $true to display key values in logs, pass -logValues as parameter.
  • json: By default set to $false. If you use appsettings.json file for configuration settings set it to $true, pass -json as parameter.
    .\scripts\set_AppConfig_for_tests ".\Ocaramba.Tests.BrowserStackCrossBrowser\bin\Debug" "Ocaramba.Tests.NUnit.dll.config" "//DriverCapabilities" "browserstack.user|browserstack.key" "key1value|key2value"

In order to display key values in logs, set logValues to $true

   .\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba.Tests.BrowserStackCrossBrowser\bin\Debug" "Ocaramba.Tests.NUnit.dll.config" "//DriverCapabilities" "browserstack.user|browserstack.key" "key1value|key2value" -logValues 

In case your configuration parameters are located in appsettings.json, set json to $true

   .\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba.Tests.NUnit" "appsettings.json" "appSettings" "browser|PathToEdgeDriverDirectory" "Edge|C:\\Temp\\Drivers" -logValues -json
Clone this wiki locally