Azure Pipelines

You can integrate Azure DevOps Pipelines with Testmo and submit your automated test results to Testmo from your builds. This usually requires only a few lines of code and is easy to set up. Any test automation tool, framework and platform can be used.

Also works with Azure DevOps issue tracking

You can also integrate Testmo with Azure DevOps to link work items and issues.

We support both simple CI pipelines (e.g. running just a single test automation suite) as well as complex workflows with multiple test suites (e.g. frontend, backend, API etc.) and even parallel test jobs with multiple threads.

Regardless of the complexity of your Azure pipelines and workflow, the basic concept of how to integrate with Testmo is always the same:

  1. You execute your automated tests as part of your Azure CI pipeline. It doesn't matter if you run a single test suite, multiple test suites or even parallel test jobs.

  2. You configure your automated tests to generate a result file using the standard JUnit XML file format. This file format has become the de facto standard format to exchange test results between testing tools. So practically any test automation tool and framework either supports this format directly or can convert to this format.

  3. You then use the Testmo CLI tool to easily submit the results to Testmo, enabling you to track your test suites over time, identify problematic test cases and improve testing performance.

Basic Azure Pipelines & Testmo workflow

The following Azure Pipelines workflow shows how to run a simple test automation run as part of your CI workflow and submit the test results to Testmo. In this example we are using a test suite with the Mocha/Chai (Node.js/Javascript) testing framework. Remember that you can use any test automation tool and framework with Testmo and we are just using this framework for our example.

We are using the Testmo CLI tool here as it makes it very easy to run our tests and submit all results with a single command line call (using the automation:run:submit command).

We are also sending a few additional fields to Testmo here, such as a link back to the Azure Pipelines workflow run as well as the Git commit hash. These details are then displayed in Testmo along with the test results, console output, exit code etc.

You can find the full code for this project on GitHub in the example project repository:

GuideCode: Azure DevOps Pipelines Test Automation & Reporting ➞

Important: For this code to work, it is required to define the secret variables TESTMO_TOKEN and TESTMO_URL in Azure with your Testmo address and API token as explained below.

# azure-pipelines.yml

trigger:
- main

variables:
- group: 'Testmo'

pool:
  vmImage: ubuntu-latest

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '19.x'
  displayName: 'Install Node.js'

# Install your project packages & dependencies here
# [..]

# Install Testmo CLI tool locally (then use npx testmo .. to run it)
- script: |
    npm install --no-save @testmo/testmo-cli
  displayName: 'Install Testmo CLI'

# Optionally add a couple of fields such as the git hash and link to the build
- script: |
    npx testmo automation:resources:add-field --name git --type string \
      --value ${GIT_COMMIT:0:7} --resources resources.json
    RUN_URL="$BUILD_URL$BUILD_PROJECT/_build/results?buildId=$BUILD_ID"
    npx testmo automation:resources:add-link --name build \
      --url $RUN_URL --resources resources.json
  env:
    GIT_COMMIT: '$(Build.SourceVersion)'
    BUILD_URL: '$(System.TeamFoundationCollectionUri)'
    BUILD_PROJECT: '$(System.TeamProject)'
    BUILD_ID: '$(Build.BuildId)'
  displayName: 'Add commit hash and link'

# Run automated tests and report results to Testmo
- script: |
    npx testmo automation:run:submit \
      --instance "$TESTMO_URL" \
      --project-id 1 \
      --name "Test run" \
      --source "frontend" \
      --resources resources.json \
      --results results/*.xml \
      -- <your-test-command> # Run your automation tool; note space after --
  env:
    TESTMO_TOKEN: '$(TESTMO_TOKEN)'
    TESTMO_URL: '$(TESTMO_URL)'
  displayName: 'Run tests and report results to Testmo'

Full example repository on GitHub

Advanced Azure DevOps Pipelines workflows

You an also easily integrate advanced Azure DevOps pipelines and workflows with Testmo. Consider the following scenarios:

  • Running multiple test suites in a build If you have multiple test suites for your project (such as frontend, backend, API, mobile tests etc.) you can simply submit these as separate test runs from the same pipeline. You would just use multiple calls to automation:run:submit to submit each test suite separately. Important: if you have different test suites, you need to use different source names for the test runs in Testmo. This way Testmo can differentiate where the test results are coming from. Learn more about test automation sources.

  • Using parallel test jobs with Azure Pipelines Testmo also fully supports tracking test runs with multiple parallel testing jobs. So if you have configured your Azure pipeline to run multiple parallel jobs to speed up your test execution, you can also submit each job as a separate thread of the same run to Testmo. You can learn more about how to implement this in the Testmo CLI: Parallel test jobs in CI/CD pipelines article.

Important security considerations

When working with the Testmo API and CLI to submit test automation results to Testmo, you need to specify an API key for the authentication. You can learn more about generating API keys in Testmo here.

When integrating Testmo with your Azure Pipelines workflows, it is important not to store the API key in your code repository. If you store the API key in your code repository, everyone with access to the repository would be able to access the key. You should never add and store your Testmo API key as part of your code repository.

Instead, use Azure Pipelines's secret variables feature to securely store keys and passwords. You can then make these secrets available as environment variables in your pipeline. You can see this in the example configuration above. You can also learn more about Azure Pipelines secret variables in the official documentation.

Last updated