pio test

Helper command for local Unit Testing.

Usage

pio test [OPTIONS]

Description

Run project tests on host (local) machine using PlatformIO Unit Testing.

Options

-e, --environment

Process specified project environment. Multiple environments are allowed.

-f, --filter

Process only test suites whose path relative to the test_dir matches the specified pattern. See documentation for the test_filter project configuration option for more details.

Example, pio test --filter "test_common" -f "native/*"

-i, --ignore

Ignore test suites whose path relative to the test_dir matches the specified pattern. See documentation for the test_ignore project configuration option for more details.

For example, pio test --ignore "embedded/*" -i "test_suite[13]"

--upload-port

A port that is intended for firmware uploading. To list available ports please use the pio device list command.

If the upload port is not specified, PlatformIO will try to detect it automatically.

--test-port

A Serial/UART port that PlatformIO uses as a communication interface between PlatformIO Unit Test Engine and target device. To list available ports please use pio device list command.

If test port is not specified, PlatformIO will try to detect it automatically.

-d, --project-dir

Specify the path to the project directory. By default, --project-dir is equal to a current working directory (CWD).

-c, --project-conf

Process project with a custom “platformio.ini” (Project Configuration File).

--without-building

Skip the building stage.

--without-uploading

Skip the uploading stage.

--without-testing

Skip the testing stage.

--no-reset

Disable software reset via Serial.DTR/RST before test running. In this case, need to press the “reset” button manually after firmware uploading.

Warning

If the board does not support software reset via Serial.DTR/RTS you should add >2 seconds delay before UNITY_BEGIN(). We need that time to establish a Serial communication between the host machine and the target device. See Unit Testing.

--monitor-rts

Set initial RTS line state for Serial Monitor (0 or 1), default 1. We use it to gather test results via a Serial connection.

--monitor-dtr

Set initial DTR line state for Serial Monitor (0 or 1), default 1. We use it to gather test results via a Serial connection.

-a, --program-arg

Pass an extra argument to the testing program. Multiple arguments are allowed.

If you need to pass extra arguments permanently per a testing environment, please take a look at the test_testing_command.

Example

> pio test --program-arg "--abort-after=1" --program-arg="-s"
# or short format
> pio test -a "-aa=1" -a "-s"
--list-tests

List project tests without processing. The pio test --json-output-path or pio test --junit-output-path options can be used for dumping available test suites.

--json-output

Return the output in JSON format.

--json-output-path

Generate a unit testing report in the JSON format and save it to the specified path. If the only folder path is provided, the file name will be generated automatically. Please note that the parent folder must exist before.

--junit-output-path

The same as pio test --json-output-path but generates a report in the JUnit XML format.

-v, --verbose

Control verbosity level.

Level

Description

(none)

Normal verbosity (default)

-v

Show a raw output from a testing framework

-vv

Base verbosity for buidling and uploading stages

-vvv

Extra verbosity for buidling and uploading stages

Examples

For the examples please follow to Unit Testing page.