Helper command for local Unit Testing.
pio test [OPTIONS]
Run project tests on host (local) machine using PlatformIO Unit Testing.
Process specified project environment. Multiple environments are allowed.
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 |
|
matches any character in seq |
|
matches any character not in seq |
For example, pio test --filter "mytest*" -i "test[13]"
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 |
|
matches any character in seq |
|
matches any character not in seq |
For example, pio test --ignore "mytest*" -i "test[13]"
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.
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.
Specify the path to the project directory. By default, --project-dir
is equal
to a current working directory (CWD
).
Process project with a custom “platformio.ini” (Project Configuration File).
Skip the building stage.
Skip the uploading stage.
Skip the testing stage.
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.
Set initial RTS
line state for Serial Monitor (0
or 1
),
default 1
. We use it to gather test results via a Serial connection.
Set initial DTR
line state for Serial Monitor (0
or 1
),
default 1
. We use it to gather test results via a Serial connection.
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 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.
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.
The same as pio test --json-output-path
but generates a report in the
JUnit XML
format.
Shows detailed information when processing environments.
For the examples please follow to Unit Testing page.