Unit Testing with Microsoft Native Unit Testing


I’ve implemented a sample Unit Test as new project next to my Juce audio plug-in project - all in Visual Studio. Now I’ve created a “Test” class in my audio plug-in and in my Unit Test project I’m using this test class:

#include "pch.h"
#include "CppUnitTest.h"
#include "../Source/Test.h" // this is my test class in the audio plug-in project

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace UnitTest
	    	Test myTest;
		    bool result = t.testReturnsTrue();

The test class has just a simple method, returning the boolean “true”. I can start the test in Visual Studio and I see one successful test. When I change the return value to “false” the test breaks. Nice, it works. :slight_smile:

But as soon as I include a class that uses Juce, then I get a lot of errors like “Cannot open include file: ‘JuceHeader.h’: No such file or directory”

For example when I have (in my audio plug-in project) a class Abc that extends the Juce Synthesiser class and I want to test one method of my Abc class in the Unit Test project. That’s not working, maybe you can give me a hint what I’m missing? :slight_smile:

Thanks in advance

P.S: Yes I saw that Juce itself offers Test classes, but that’s a different story.

I’ve tried it with this setting:


Now I’ve different errors:

What is it, that I’m missing? Any ideas? :slight_smile:

I was able to fix the issue. “Configuration Type” was wrong for the project.