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 with
pio test -e native --filter="path/to/test_something"

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

Screenshot 2022-12-04 at 11.18.53

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

So… the current workflow is:

  1. Modify 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 in favour of some native IDE functionality.

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

Screenshot 2022-12-04 at 11.11.57

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:

  • you can use a shortcut or right-click in the test source to run/debug a specific test method:
    Screenshot 2022-12-04 at 14.55.21
  • or all test methods from the test class:
    Screenshot 2022-12-04 at 15.01.32
  • it shows up automatically in the build toolbar then
    Screenshot 2022-12-04 at 14.58.31

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



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: