I'm attempting to create unit tests in my C++ project for the first time, but they simply won't run.
Attempted:
- I've followed the instructions on the MS Docs site
- Went through several answers from this SO question including:
- Manually setting the Platform Target and the Test settings default processor architecture
- Restarted VS (and my machine)
- Changed several project properties in my "UnitTesting" project(nested inside of the main project(solution?) folder to match the "base project" (statically linked executable)
After changing some of the project properties to match the base the project(static linkage because base program is statically linked) and adding a reference to the "base project" from the "test project", I got rid of the errors, but the tests just don't run... A quick google search for the tests not running lead me to check the "tests" dropdown in the output window, but the error message there doesn't appear to provide me any meaningful context:
Here's the very simple test code I'm attempting to run:
#include "pch.h"
#include "CppUnitTest.h"
#include "../SysLatData.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTesting
{
TEST_CLASS(UnitTesting)
{
public:
TEST_METHOD(TestMethod1)
{
Assert::AreEqual(1, 1);
}
};
}
I guess these are my questions:
- Am I missing something obvious to get this very simple test to work?
- Should the "UnitTesting" project be built as an executable like the base project is?
- Or should it be built as a static library that can be "built into" the base program at the "base project" build time?
Any help understanding this issue would be greatly appreciated.
Here's my source code: https://github.com/Skewjo/SysLat_Software/tree/CreateUnitTests