hatch-test - Man Page

hatch test – Run tests using the hatch-test environment matrix

Synopsis

hatch test [Options] [ARGS]...

Description

Run tests using the hatch-test environment matrix.

If no filtering options are selected, then tests will be run in the first compatible environment found in the matrix with priority given to those matching the current interpreter.

The -i/--include and -x/--exclude options may be used to include or exclude certain variables, optionally followed by specific comma-separated values, and may be selected multiple times. For example, if you have the following configuration:

[[tool.hatch.envs.hatch-test.matrix]]

python = ["3.9", "3.10"] version = ["42", "3.14", "9000"]

then running:

hatch test -i py=3.10 -x version=9000

would run tests in the environments test.py3.10-42 and test.py3.10-3.14.

The -py/--python option is a shortcut for specifying the inclusion -i py=....

Options

-r,  --randomize

Randomize the order of test execution

-p,  --parallel

Parallelize test execution

--retries INTEGER

Number of times to retry failed tests

--retry-delay FLOAT

Seconds to wait between retries

-c,  --cover

Measure code coverage

--cover-quiet

Disable coverage reporting after tests, implicitly enabling --cover

--cover-xml

Generate XML coverage report after tests, implicitly enabling --cover

--cover-xml-output PATH

Path for the XML coverage report file

-a,  --all

Test all environments in the matrix

-py,  --python TEXT

The Python versions to test, equivalent to: -i py=...

-i,  --include TEXT

The matrix variables to include

-x,  --exclude TEXT

The matrix variables to exclude

-s,  --show

Show information about environments in the matrix

-h,  --help

Show a help message and exit

Notes

The inclusion option is treated as an intersection while the exclusion option is treated as a union i.e. an environment must match all of the included variables to be selected while matching any of the excluded variables will prevent selection.

See Also

hatch-build(1), hatch-check(1), hatch-clean(1), hatch-config(1), hatch-dep(1), hatch-env(1), hatch-fmt(1), hatch-lock(1), hatch-new(1), hatch-project(1), hatch-publish(1), hatch-python(1), hatch-run(1), hatch-self(1), hatch-shell(1), hatch-status(1), hatch-version(1)

hatch(1)

Referenced By

hatch(1), hatch-build(1), hatch-check(1), hatch-clean(1), hatch-config(1), hatch-dep(1), hatch-env(1), hatch-fmt(1), hatch-lock(1), hatch-new(1), hatch-project(1), hatch-publish(1), hatch-python(1), hatch-run(1), hatch-self(1), hatch-shell(1), hatch-status(1), hatch-version(1).

June 2026