CircleCI
Testmo comes with full CircleCI integration so you can submit your automated test results from your CircleCI pipeline to Testmo to implement CircleCI test management. This only requires a few lines of code and is easy to set up. Any test automation tool, framework and platform can be used.
You can integrate simple CircleCI pipelines (such as 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 your specific configuration and workflow, the basic concept of integrating your CircleCI pipeline with Testmo is always the same:
  1. 1.
    You execute your automated tests as part of your CircleCI pipeline. It doesn't matter if you run a single test suite, multiple test suites or even parallel test jobs.
  2. 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. 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 CircleCI & Testmo workflow

The following CircleCI configuration 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 (NodeJS/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 CircleCI 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. You can also find a detailed explanation of this project along with more code samples and screenshots in our reference guide:
# .circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: cimg/node:current
steps:
- checkout
# Restore previous node package cache if there is one
- restore_cache:
key: node-{{ checksum "package-lock.json" }}
# Install or update packages
- run: npm ci
# Save cache
- save_cache:
key: node-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
# Store project files for the next job
- persist_to_workspace:
root: ~/
paths:
- project
test:
docker:
- image: cimg/node:current
steps:
# Start with the initial build
- attach_workspace:
at: ~/
# Install Testmo CLI tool
- run: npm install --no-save @testmo/testmo-cli
# Optionally add a couple of fields such as the git hash and link to the build
- run:
command: |
npx testmo automation:resources:add-field --name git --type string \
--value ${CIRCLE_SHA1:0:7} --resources resources.json
npx testmo automation:resources:add-link --name build \
--url $CIRCLE_BUILD_URL --resources resources.json
# Run tests and report results to Testmo
- run:
command: |
npx testmo automation:run:submit \
--instance $TESTMO_URL \
--project-id 1 \
--name "Mocha test run" \
--source "unit-tests" \
--resources resources.json \
--results results/*.xml \
-- npm run mocha-junit # Note space after --
# Store test artifacts and results
- store_artifacts:
path: results
destination: test_results
- store_test_results:
path: results
workflows:
version: 2
full:
jobs:
- build
- test:
requires:
- build
context:
- testmo

Advanced CircleCI workflows

We also support advanced CircleCI workflows. For example, you can submit test results for many test suites from a CircleCI workflow and Testmo also fully supports parallel test runs.
  • 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 CircleCI 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 CircleCI Testmo also fully supports tracking test runs with multiple parallel testing jobs. So if you have configured your CircleCI 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 implementing this in the following example.

CircleCI parallel testing workflow

Testmo fully supports CircleCI workflows with parallel test steps, so you can submit the results as separate threads of the same run to Testmo. You can then see the results (and console output, exit codes & testing times) of each thread separately, as well as the overall results and statistics for the entire test run in Testmo. The following illustration shows how to implement the workflow with CircleCI.
Example parallel testing workflow
In this workflow we use separate jobs to set up our test run (test-setup), then submit a thread for each testing job of the run (test), and finally mark the test run as completed (test-complete).
We have a detailed guide with example code, screenshots and explanations on implementing this for CircleCI. You can also find a complete example project repository on GitHub. You can find the full guide here:
# .circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: cimg/node:current
steps:
- checkout
# Restore previous node package cache if there is one
- restore_cache:
key: node-{{ checksum "package-lock.json" }}
# Install or update packages
- run: npm ci
# Save cache
- save_cache:
key: node-{{ checksum "package-lock.json" }}
paths:
- ~/.npm
# Store project files for the next job
- persist_to_workspace:
root: ~/
paths:
- project
test-setup:
docker:
- image: cimg/node:current
steps:
# Start with the initial build
- attach_workspace:
at: ~/
# Optionally add a couple of fields such as the git hash and link to the build
- run:
name: Set up resources
command: |
npx testmo automation:resources:add-field --name git --type string \
--value ${CIRCLE_SHA1:0:7} --resources resources.json
npx testmo automation:resources:add-link --name build \
--url $CIRCLE_BUILD_URL --resources resources.json
# Create test run in Testmo and store ID in file
- run:
name: Create test run in Testmo
command: |
npx testmo automation:run:create \
--instance $TESTMO_URL \
--project-id 1 \
--name "Parallel mocha test run" \
--resources resources.json \
--source "unit-tests" > testmo-run-id.txt
# Update workspace to persist run ID file
- persist_to_workspace:
root: ~/
paths:
- project
test:
docker:
- image: cimg/node:current
parallelism: 4
steps:
# Start with the initial build
- attach_workspace:
at: ~/
# Split & run tests and report results to Testmo
- run:
name: Split and run tests
command: |
npx testmo automation:run:submit-thread \
--instance $TESTMO_URL \
--run-id $(cat testmo-run-id.txt) \
--results results/*.xml \
-- npm run mocha-junit-parallel # Note space after --
# Store test artifacts and results
- store_artifacts:
path: results
destination: test_results
- store_test_results:
path: results
test-complete:
docker:
- image: cimg/node:current
steps:
# Start with the initial build
- attach_workspace:
at: ~/
# Mark run as completed
- run:
name: Mark run as completed
command: |
npx testmo automation:run:complete \
--instance $TESTMO_URL \
--run-id $(cat testmo-run-id.txt)
deploy:
docker:
- image: cimg/node:current
steps:
# Start with the initial build
- attach_workspace:
at: ~/
# You would deploy your code here
- run: echo "Deploying code here"
workflows:
version: 2
full:
jobs:
- build:
context:
- testmo
- test-setup:
requires:
- build
context:
- testmo
- test:
requires:
- test-setup
context:
- testmo
- test-complete:
requires:
- test
context:
- testmo
- deploy:
requires:
- test-complete
context:
- testmo

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 CircleCI pipeline, it is important not to store the API key in your code repository. If you store the API key in your code repository (e.g. in Git), 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 CircleCI's secrets 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, as well as in our detailed CircleCI guide. You can also learn more about CircleCI secret management in the official documentation.
Copy link
On this page
Further links, references and guides
Basic CircleCI & Testmo workflow
Advanced CircleCI workflows
CircleCI parallel testing workflow
Important security considerations