Integration with CI/CD Pipelines
Integrating your Ranorex tests into a Continuous Integration/Continuous Deployment (CI/CD) pipeline is essential for modern software development. This guide provides an overview of how to run Ranorex tests from the command line and integrate them into popular CI/CD tools.
Command-Line Execution
Ranorex tests can be executed from the command line, which is the foundation for CI/CD integration.
Running a Test Executable
Your Ranorex project compiles into an executable that you can run from the command line with various arguments.
Example:
# Run the entire test suite
MyProject.exe
# Run a specific test case
MyProject.exe /testcase:MyTestCase
# Generate a JUnit report
MyProject.exe /reportfile:report.xml /reportlevel:Info /reporttype:JUnit
Key Command-Line Arguments
/testcase:<name>: Runs a specific test case./testsuite:<name>: Runs a specific test suite file./reportfile:<path>: Specifies the path for the report file./reportlevel:<level>: Sets the report level (e.g.,Info,Warn,Error)./reporttype:<type>: Specifies the report format (e.g.,Ranorex,JUnit).
Integrating with Jenkins
Jenkins is a popular open-source automation server that can be used to build and test your software.
Jenkins Pipeline Script
You can use a Jenkinsfile to define your pipeline as code.
Example (Jenkinsfile):
pipeline {
agent any
stages {
stage('Build') {
steps {
// Build your application
bat 'msbuild MyApp.sln /p:Configuration=Release'
}
}
stage('Test') {
steps {
// Run Ranorex tests
bat 'MyRanorexProject.exe /reportfile:report.xml /reporttype:JUnit'
}
}
}
post {
always {
// Publish test results
junit 'report.xml'
}
}
}
Integrating with Azure DevOps
Azure DevOps provides developer services for support teams to plan work, collaborate on code development, and build and deploy applications.
Azure Pipelines YAML
You can define your build and release pipelines using YAML.
Example (azure-pipelines.yml):
trigger:
- main
pool:
vmImage: 'windows-latest'
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- task: VSBuild@1
inputs:
solution: 'MyApp.sln'
platform: 'Any CPU'
configuration: 'Release'
- stage: Test
jobs:
- job: TestJob
steps:
- script: |
MyRanorexProject.exe /reportfile:report.xml /reporttype:JUnit
displayName: 'Run Ranorex Tests'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/report.xml'
Integrating with GitHub Actions
GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD.
GitHub Actions Workflow
You can create a workflow file in your repository's .github/workflows directory.
Example (.github/workflows/ci.yml):
name: CI
on: [push]
jobs:
build-and-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: msbuild MyApp.sln /p:Configuration=Release
- name: Run Ranorex Tests
run: ./MyRanorexProject.exe /reportfile:report.xml /reporttype:JUnit
- name: Publish Test Results
uses: actions/upload-artifact@v2
with:
name: test-results
path: report.xml
By integrating your Ranorex tests into a CI/CD pipeline, you can automate your testing process, get faster feedback, and ensure a higher level of quality for your application.