How can I read the runtime parameters passed to C++ unit tests when it is running under vstest.console.exe or as VSTest task in Azure DevOps build pipeline?
I am trying to read the runtime parameters set in .runsettings file or passed through overrideTestrunParameters but unable to find a way to do this.
Looks like TestContext is available only for C# based tests and not available to unmanaged C++ unit tests.
I am trying to read the runtime parameters set in .runsettings file
In Azure Devops, you could directly use the PowerShell task to read the runtime parameters in .runsettings file:
Here is an example:
test.runsettings
<!-- Parameters used by tests at runtime -->
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost" />
<Parameter name="webAppUserName" value="Admin" />
<Parameter name="webAppPassword" value="Password" />
</TestRunParameters>
Pipeline PowerShell task InLine Script:
[xml]$DSConfig = gc "$(build.sourcesdirectory)/test.runsettings" #file path
# Select <parameters> nodes
$ParametersNode = $DSConfig.SelectNodes('//Parameter')
foreach($Node in $ParametersNode)
{
echo Name: $Node.name Value: $Node.value
}
Result: