Basic unit test setup

Hey JUCE people,

we started a desktop application with JUCE which runs good on macOS. Now we want to write unit tests, but do not know what is a good or preferred setup / structure of our project. For sure, it always depends, but maybe there is a common way how to structure a JUCE project?

I started to change the structure of our project from one JUCE projucer project to:
app => Main projucer application, includes core
core => module (or maybe static library) with the core source code
test => Test projucer application which starts the tests with the UnitTestRunner, includes core

Is a good way to go?

Side note: Later we like to run this via command line, maybe with cmake, but the test app can also be a command-line application.


Yes, the setup you’ve outlined sounds sensible. You could take a look at the way the JUCE UnitTestRunner works for inspiration: all the test code lives inside the JUCE modules (in your case, it would live in the core module) and is enabled with a preprocessor flag. Then, the core module can be included both in your desktop application, and a command-line test driver application.

1 Like