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 the tests where the name matches specified patterns. More than one pattern is allowed. If you need to filter some tests for a specific environment, please take a look at test_filter option from “platformio.ini” (Project Configuration File).

Pattern

Meaning

*

matches everything

?

matches any single character

[seq]

matches any character in seq

[!seq]

matches any character not in seq

For example, pio test --filter "mytest*" -i "test[13]"

-i, --ignore

Ignore tests where the name matches specified patterns. More than one pattern is allowed. If you need to ignore some tests for a specific environment, please take a look at test_ignore option from “platformio.ini” (Project Configuration File).

Pattern

Meaning

*

matches everything

?

matches any single character

[seq]

matches any character in seq

[!seq]

matches any character not in seq

For example, pio test --ignore "mytest*" -i "test[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-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.