CLion: how to run a single test?

There is a simple way to run all tests for given env:

Screenshot 2022-12-04 at 09.28.40

It is actually calling /usr/local/bin/platformio -c clion test -e native.

So, how about running a SINGLE test to speed up TDD process?

In CLI I can do:
pio test -e native --filter="native/DnLogger/Endpoint/test_PrinterLogger"

Is there a way to do something similar in CLion?

For now I have created a script file run_test.sh with
pio test -e native --filter="path/to/test_something"

I’ve also set up External Tools that runs the script.

Finally, I’ve configured a shortcut to run the external tool in Keymap settings.


So… the current workflow is:

  1. Modify run_test.sh with the test I’m working with now
  2. Hit a shortcut to run it.

Kinda OK. I wish I could get rid of the run_test.sh in favour of some native IDE functionality.

Plus, I don’t know why the output is not coloured the way it is in CLI:

Would PR Added CLion IDE CTest support by hacker-cb · Pull Request #4408 · platformio/platformio-core · GitHub solve this?

I don’t know.

But, coming from PhpStorm:

The lack of colors was PIO’s [?] fault. I grepped the source code for ansi and found PLATFORMIO_FORCE_ANSI env var.

#!/bin/bash

export PLATFORMIO_FORCE_ANSI=true

pio test -e native --filter="native/DnLogger/Endpoint/test_PrinterLogger"

Now the colors work in the CLion’s output.

Even better, with autorefresh of the test when files change: