Skip to main content

Test Runner

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/test-runner

In short

A test runner is a tool that finds a project's automated tests, executes them, and reports which ones passed or failed, usually from a single command.

What is a test runner?

A test runner is the program that actually runs your automated tests. You start it with one command, such as npm test, pytest, or go test, and it finds the tests, runs them, and prints a summary of what passed and what failed. It exits with a nonzero exit code when any test fails, which is how a CI/CD pipeline knows to stop a broken change.

A runner first discovers tests, usually by file name patterns such as *.test.js or test_*.py, or by annotations in the code. It then sets up fixtures, runs each test, often in parallel across several worker processes, captures output and timing, and produces a report: a console summary, or a machine-readable file such as JUnit XML that CI systems can display. Useful features include a watch mode that reruns tests when files change, filtering by name or tag, rerunning only failed tests, timeouts for tests that hang, and shuffling the test order to expose tests that depend on each other.

A test runner is like the referee and scoreboard at a tournament: it doesn't play the games, but it makes sure each one is played under the rules and records the results. Every major language ecosystem has at least one, and some are built into the language's toolchain, such as node --test in Node.js, go test in Go, and cargo test in Rust.

Test runners are often confused with testing frameworks and assertion libraries. The framework provides the API for writing tests, such as describe, test, and fixture hooks; the assertion library provides the checks, such as expect(x).toBe(y); and the runner executes the tests and reports results. Many popular tools bundle all three, which is why the names are often used interchangeably. A CI server is different again: it runs the test runner as one step of a larger pipeline.

Key takeaways

  • A test runner discovers, executes, and reports on automated tests.
  • A nonzero exit code on failure lets CI pipelines block broken changes.
  • Common features include parallel runs, watch mode, filtering, and timeouts.
  • Reports can be human-readable or machine-readable, such as JUnit XML.
  • The framework defines how tests are written; the runner executes them.

Example

Common test runner commandsbash
# Discover and run all test files with Node.js's built-in runner
node --test

# Run only the tests whose names match a pattern
node --test --test-name-pattern="checkout"

# Rerun affected tests automatically whenever a file changes
node --test --watch

# Python: run tests matching "checkout" and stop at the first failure
pytest -k checkout -x

# 0 means every test passed; anything else means at least one failed
echo $?

Readers ask

What is the difference between a test runner and a testing framework?

A testing framework gives you the functions for writing tests and organizing them, while the test runner finds and executes those tests and reports the results. Many tools include both, so the terms are often used loosely.

Why do test runners run tests in parallel?

Running tests at the same time across several processes shortens the feedback loop, which matters for large suites. It only works reliably when tests are independent and don't share data they modify.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings