Unit testing!

Hello everyone! I’m a computer science student wanting to improve my skills on a real project. I’m making a synth plugin right now and I want to write tests. Catch2 or doctest both appeal to me bc of the operator overloading that just feels more intuitive. I set up my JUCE projects with the projucer and I develop in Visual Studio. I can import either library just fine with vcpkg, but i would love to make a new project that’s seperate from my JUCE code, but can also have access to the source code I’ve written. I’ve heard about Pamplejuce, and while that looks very helpful, This is an existing project and I’d rather not start from scratch. I haven’t used Cmake for this project (MSBuild so far). I’m not opposed to it, but I’d rather not add another build system just to make tests, unless that is recommended. Any suggestions help. Thanks!

Typically for unit tests you would keep them near your project’s source code rather than putting them in an entirely separate project. E.g. a tests/ directory next to your src/ directory. You’d then set up a separate target in your build system to run the tests.

In Visual Studio you’d likely have your project’s solution file (.sln) and then have several projects within it - one of which should be your testing target. This allows you to quickly switch between your tests and your project just from a dropdown.

I’ve tried adding a new project to visual studio for tests but I just get linker or build errors when I do that, even if the files in that test project are in the same directory as the source files I made