We’re trying to include Catch2 tests. This was my intended strategy (MacOS, XCode / AppCode):
- Create new folder
source/tests. - Add
catch.hppandtests.cppto folder. - Create new target
tests. - Set header search paths for
teststo mimic those of other plugin targets. tests.cpp:
#include "catch.hpp"
#include <JuceHeader.h>
#include "project_module_to_test.cpp"
... Tests ...
- Create build config for
teststarget. - Build and run.
Unfortunately this gives an error: No global header file was included!. This references JuceHeader.h which suggests silencing the error using #define JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED.
Attempted fix: Add this to the top of tests.cpp.
Result: Lots of linker errors.
At this point I notice that the plugin targets include (in build phases) the JUCE implementation files from JUCE Library Code as source.
Attempted fix: Add these files to the source for the tests target.
Result: Lots more errors including (mysteriously) the return of the initial No global header file error.
At this point I decide that there is something going way, way, way over my head.
Is this a completely misguided way of configuring Catch2 tests for JUCE or is there something small I’m missing?
Cheers!
