Using Catch2 but need a MessageLoop

I’m using Catch2 as my unit test framework, which for most cases has worked pretty good so far. Some JUCE classes need a running MessageLoop to work properly, so need to create one on startup of the test executable. From what I can tell, I have to options:

1

Use a JUCE GuiApplication as the test runner. Catch2 needs argc & argv, so I would need to get them from somewhere. Not sure how. Since it would be a GUI application, I would also need extra setup on the docker test runners to fake a display.

2

Manually start the MessageLoop. This is what I’ve been doing so far, but I’m not sure if I’m doing it correctly:

#define CATCH_CONFIG_RUNNER
#include "catch2/catch.hpp"

int main(int argc, char* argv[])
{
    auto gui = juce::ScopedJuceInitialiser_GUI {};
    return Catch::Session().run(argc, argv);
}

Ideally I’d like to be able to test plugins this way, so setting parameters & running the processBlock method. I’ve had some weird results where I was setting a parameter to a new value but it still contained the old value when checking. Any suggestions?

What you are doing in method number 2 is essentially what I do (I use google test though not catch).

If you are using cached values then that might explain the issue with the parameter not updating. I have had some issues dealing with value tree updates and cached values in my unit tests. If you are using cached values forcing the update of the cached value might work. You might take a look at this thread and check out Daves answer. I ended up using an async updater and calling handleUpdateNowIfNeeded in my tests and that seemed to work well.