Run extra_scripts when using pio test

Hello,
we are using the extra_scripts option to run a script before the build stage of our project. However, this does not seem to work when using pio test.

The docs on Advanced Scripting mention that “[…] They will be loaded automatically when the pio run command processes the project environment”, so I assume that the extra_scripts option is only applicable when using pio run?
Is there a way we can set a pre-hook when using pio test?

Many thanks,
Alex

I guess a forced way would be to specify a custom test runner that inherits from your original one (e.g. Unity or GoogleTest) and then putting your logc in the configure_build_env callback.

https://docs.platformio.org/en/latest/advanced/unit-testing/frameworks/custom/examples/custom_unity_library.html

Can you give a simple example of where it doesn’t work?