Can I add a shortcut to vscode to run platformio tests?

I’d like to be able to invoke tests easier - searching through the project tasks for the ‘advanced>test’ option when there are a lot of target environments is a pain every time I make a small change and want to re-run the tests

Is there any way to add a shortcut? - ideally like the ‘build’ button on the status bar

The toolbar is sadly non-modifyable from a user perspective, it needs adaptions in the extension code.

In fact, there once was a “Test” button, but people said it consumed too much space, so it was removed (PlatformIO Toolbar: "PlatformIO: Test” icon · Issue #2226 · platformio/platformio-vscode-ide · GitHub) at their request.

The quickest way is via the command pallete now. Ctrl+Shift+P → Test → Enter.

Thanks for the reply, I guessed that might be the case
I guess I’m spoilt coming from visual studio that has a ‘test explorer’ view that has more features, like selecting individual tests to run

Another thought - could invoking the tests be part of a defined ‘workflow’ - i.e. a process that runs build then test (then maybe git commit if it all passes)


Yes, this is supported via the custom target API as documented in Custom Targets — PlatformIO latest documentation.

In platformio.ini add

extra_scripts =

and as

        "pio run -e $PIOENV",
        "pio test -e $PIOENV",
    title="Build & Test",
    description="Builds code and runs unit tests"

Should make a custom task appear in the project tasks.

1 Like