Coder
Coder

Reputation: 5

Unable to update the TestRunParameter in azure pipeline

The below content is from .runsettings file.

<TestRunParameters>
    <Parameter name="TestMode" value="" />
    <Parameter name="RemoteServerUrl" value="" />
    <Parameter name="ServiceIdentityOpenUrl" value="" />
    <Parameter name="TestScope" value="" />
</TestRunParameters>

The below content is vstest task of azure pipeline. The ServiceIdentityOpenUrl, TestScope and RemoteServerUrl variable are present and accessible from variable group.

 - task: VSTest@2
   displayName: Run Integration Tests
   inputs:
     testAssemblyVer2: ${{ parameters.integrationTestDllFilter }}
     configuration: '$(Build.Configuration)'
     runSettingsFile: ${{ parameters.integrationTestRunSettingsFile }}
     overrideTestrunParameters: |
       ServiceIdentityOpenUrl=$(ServiceIdentityOpenUrl)
       TestScope=$(TestScope)
       RemoteServerUrl=$(RemoteServerUrl)

But while running the pipeline it throws the below error.

##[error]SetupPhase.Run : Exception occurred during the updation of run settings: System.FormatException: Error encountered while overriding test run parameters. Please check the test run parameteres provided.
   at Microsoft.VisualStudio.TestService.SettingsManager.OverrideParamsSettingsProcessor.GetOverrideParameters(String overrdeParametersString)
   at Microsoft.VisualStudio.TestService.SettingsManager.OverrideParamsSettingsProcessor.UpdateSettingsWithParameters(XDocument settings)
   at Microsoft.VisualStudio.TestService.SettingsManager.CommonSettingsManager.UpdateCommonSettings(InputDataContract inputDataContract, SettingsModifier settingsModifier)
   at Microsoft.VisualStudio.TestService.SettingsManager.SettingsManager.UpdateSettingsAsRequired(InputDataContract inputDataContract)
   at MS.VS.TestService.VstestConsoleAdapter.SetupPhase.Run(VstestConsoleRunContext testRunContext, CancellationToken cancellationToken)
##[error]Settings updation failed with error: Error encountered while overriding test run parameters. Please check the test run parameteres provided.

Upvotes: 0

Views: 71

Answers (1)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35504

##[error]SetupPhase.Run : Exception occurred during the updation of run settings: System.FormatException: Error encountered while overriding test run parameters. Please check the test run parameteres provided.

I can reproduce the same issue when using the same VSTest Task definition.

The cause of the issue is that the format you defined in the overrideTestrunParameters field of VSTEST task is not correct.

You need to change to use the format below to update your VSTest Task:

overrideTestrunParameters: '-param1 value1 -param2 value2'

Updated Task definition:

 - task: VSTest@2
   displayName: Run Integration Tests
   inputs:
     testAssemblyVer2: ${{ parameters.integrationTestDllFilter }}
     configuration: '$(Build.Configuration)'
     runSettingsFile: ${{ parameters.integrationTestRunSettingsFile }}
     overrideTestrunParameters: '-ServiceIdentityOpenUrl $(ServiceIdentityOpenUrl) -TestScope $(TestScope) -RemoteServerUrl $(RemoteServerUrl)'

For more detailed info, you can refer to this doc: VSTest@2 - Visual Studio Test v2 task

overrideTestrunParameters - Override test run parameters

Overrides the parameters defined in the TestRunParameters section of a runsettings file or the Properties section of a testsettings file. For example: -key1 value1 -key2 value2. Note: Properties specified in a testsettings file can be accessed via the TestContext using Visual Studio 2017 (update 4 or higher).

Upvotes: 0

Related Questions