Rapise TestAdapter for VSTest. Use it to run Rapise tests with Azure Pipelines and VSTest.Console.exe.
The package is published on NuGet.org: Rapise.TestAdapter.
- If you plan to run tests on Azure Hosted agents you need to configure the installtion step for Rapise. Add PowerShell task.
steps:
- task: PowerShell@2
displayName: 'Install Rapise'
inputs:
targetType: filePath
filePath: ./RapiseInstall.ps1
arguments: '-RapiseVersion "6.5.20.21"'RapiseInstall.ps1 is located in the root of this repository. Place it into your Git repository and reference in the PowerShell task. This script downloads and installs Rapise. It also installs Rapise extension into Chrome browser.
-
Add NuGet tool installer task to install NuGet.exe.
Example:
steps: - task: NuGetToolInstaller@0 displayName: 'Use NuGet' inputs: versionSpec: 4.4.1
-
Add NuGet task. Set command to
customand specify the command line:install Rapise.TestAdapter -Version $(RapiseTestAdapterVersion)Example
steps: - task: NuGetCommand@2 displayName: 'NuGet Install Rapise.TestAdapter' inputs: command: custom arguments: 'install Rapise.TestAdapter -Version $(RapiseTestAdapterVersion)'
In the pipeline settings set RapiseTestAdapterVersion variable to the Rapise.TestAdapter version you want to install (e.g. 1.0.11). The task will install Rapise.TestAdapter into
$(Build.Repository.LocalPath)\Rapise.TestAdapter.$(RapiseTestAdapterVersion)\lib\net472 -
If you plan to run tests on a self-hosted Windows Agent that does not have Visual Studio installed you need to add Visual Studio Test Platform Installer task.
Example:
steps: - task: VisualStudioTestPlatformInstaller@1 displayName: 'Visual Studio Test Platform Installer' inputs: versionSelector: latestStable
-
To run tests you need Visual Studio Test task.
Example:
steps: - task: VSTest@2 displayName: 'VsTest - Run Rapise Tests' inputs: testAssemblyVer2: | $(Build.Repository.LocalPath)\Tests\*.sstest $(Build.Repository.LocalPath)\Tests\*\*.sstest runSettingsFile: '$(System.DefaultWorkingDirectory)\Pipeline\azure.runsettings' overrideTestrunParameters: '-g_baseURL $(Dynamics365CrmBaseURL) -g_password $(Dynamics365CrmPassword) -g_browserLibrary $(RapiseBrowserProfile)' pathtoCustomTestAdapters: '$(Build.Repository.LocalPath)\Rapise.TestAdapter.$(RapiseTestAdapterVersion)\lib\net472' platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)'
Make sure that path to custom test set adapters is set to
$(Build.Repository.LocalPath)\Rapise.TestAdapter.$(RapiseTestAdapterVersion)\lib\net472Specify patterns to search for
*.sstestfiles in the test files section (testAssemblyVer2in YAML).If you added Visual Studio Test Platform Installer task on the previous step do not forget to set
vsTestVersionin YAML (or Test platform version in Classic UI):vsTestVersion: toolsInstaller -
To publish test results (for later review and downloading) use Publish Build Artifacts task. Execution results are copied to
$(Agent.TempDirectory)\TestResults.Example:
steps: - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: TestResults' inputs: PathtoPublish: '$(Agent.TempDirectory)\TestResults' ArtifactName: TestResults
Rapise.TestAdapter also supports filtering, parameters and .runsettings files.
Rapise.TestAdapter supports filter criteria based on FullyQualifiedName test property (equals to *.sstest file name). To specify a filter set testFiltercriteria in YAML or Test filter criteria in the form-based task editor.
Example:
FullyQualifiedName~LIS
Parameters can be set via
- .runsettings file,
overrideTestrunParametersYAML option or- Override test run parameters field in the form-based task editor.
Note: Parameter names must be prefixed with
g_.
Example:
-g_baseURL $(Dynamics365CrmBaseURL) -g_password $(Dynamics365CrmPassword) -g_browserLibrary $(RapiseBrowserProfile)
Note: $(name) - references a pipeline variable
.runsettings file is used to pass parameters and to enable video recorder.
Example:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Parameters used by tests at runtime -->
<TestRunParameters>
<Parameter name="g_browserLibrary" value="Chrome" />
</TestRunParameters>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector uri="datacollector://microsoft/VideoRecorder/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder.VideoRecorderDataCollector, Microsoft.VisualStudio.TestTools.DataCollection.VideoRecorder, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" friendlyName="video" enabled="True">
<Configuration>
<MediaRecorder sendRecordedMediaForPassedTestCase="true" xmlns="">
<ScreenCaptureVideo bitRate="512" frameRate="2" quality="20" />
</MediaRecorder>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>It is also possible to run Rapise tests on a VM that has VSTest.Console.exe installed.
Let's assume that the working folder is C:\Tools.
-
Download and install NuGet.
-
Install Microsoft.TestPlatform with a command
nuget install Microsoft.TestPlatform
Find VSTest.Console.exe in C:\Tools\Microsoft.TestPlatform.16.7.1\tools\net451\Common7\IDE\Extensions\TestPlatform. Add this folder to the PATH environment variable.
-
Install Rapise.TestAdapter
nuget install Rapise.TestAdapter -
You may now create a .cmd file and put it near Rapise tests. E.g.
vstest.console.exe /TestAdapterPath:C:\Tools\Rapise.TestAdapter.1.0.11\lib\net472 /Settings:local.runsettings /TestCaseFilter:FullyQualifiedName~LIS *\*.sstest