Skip to main content

Run tests in CI pipelines

You can run all types of tests in CI pipeline, including integration tests, functional tests, mutation tests, unit tests, and more.

To run tests in CI pipelines, you can use Run steps or Test Intelligence steps (also known as Test steps).

You can run any type of test for any codebase in a Run step.

For example, this step runs pytest and produces a test report in JUnit XML format.

              - step:
type: Run
name: Pytest
identifier: Pytest
spec:
shell: Sh
command: |-
pytest test_main.py --junit-xml=output-test.xml
reports:
type: JUnit
spec:
paths:
- output-test.xml

For more information about configuring Run steps, go to Use Run steps.

tip

Harness supports code coverage in Run steps.

Improve test times

These Harness CI features can improve test times:

You might also try these test optimization practices:

  • Use mock services in your unit tests, rather than setting up and connecting to third-party services. Mockups can often test your code as well as fully-running services but with fewer resources.
  • Avoid integration tests in your build pipelines when possible. You might want to move these to a separate pipeline.
  • Look for obsolete tests that you can delete.
  • Look for unnecessary sleep statements in your unit test code.
  • Order your tests so that the tests most likely to fail run first.

Test results

You can view test results in Harness.

Troubleshoot tests in Harness CI

Go to the CI Knowledge Base for questions and issues related to running tests in Harness CI, including: