So I have a project called OpenGLStuffs that I am developing with Visual Studio. I am trying to do tests for this project. I created a separate test project called AppTest. In this test project I have a cpp file called AppTest.cpp that I will use to run the test version of the app. Here is the content of the test file:
AppTest.cpp
#include "pch.h"
#include "CppUnitTest.h"
#include "../openGL/OpenGLStuffs/MainApp.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace AppTest
{
TEST_CLASS(AppTest)
{
public:
TEST_METHOD(TestMethod1)
{
runApp();
}
};
}
Here's the content of the header file that is tested, it has a single line:
MainApp.h
const int runApp();
I already have a MainApp.cpp file that defines the runApp()
function. It is too long so I’m not posting it here.
The problem is that as I tried rebuilding the AppTest project, Visual Studio is giving me this error:
Error LNK2019 unresolved external symbol "int const __cdecl runApp(void)" (?runApp@@YA?BHXZ)
referenced in function "public: void __thiscall AppTest::AppTest::TestMethod1(void)" (?
TestMethod1@AppTest@1@QAEXXZ) AppTest C:\my-space\my-stuffs\AppTest\AppTest.obj 1
I tried adding references to OpenGLStuffs to AppTests, but it doesn't seem to be working. I also tried changing the configuration type to .lib instead of .dll and the rebuilding succeeded, but this makes the test explorer to not show any tests.
Could somebody please tell me what I got wrong? Thanks in advance!