option(YOURPLUGIN_BUILD_TESTS "Build the unit tests with Catch2" ON)
if(YOURPLUGIN_BUILD_TESTS)
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rd_party/Catch2/contrib")
enable_testing()
add_subdirectory(3rd_party/Catch2 EXCLUDE_FROM_ALL)
include(CTest)
include(Catch)
endif()
Write Test
main
We need to write a custom main for Catch, since we need to initialize & shutdown JUCE.
#include"JuceHeader.h"#defineCATCH_CONFIG_RUNNER#include"catch2/catch.hpp"intmain(int argc,char* argv[]){ juce::initialiseJuce_GUI();int result = Catch::Session().run(argc, argv); juce::shutdownJuce_GUI();return result;}
processor
Simple tests checking the plug-in name & if a mono bus layout is supported.