我收到标题中所述的错误。我确保以下各项:
-正确设置了Include目录,include库和其他include目录
-在属性中,Subsystem设置为CONSOLE
对我的代码的注释:LifeLib是一个项目,其中包含我要测试某些方法的类。这些类在命名空间LifeLib中定义。StornoTafel就是其中之一。在任何名称空间中均未定义testVariables。
对于StornoTafel中的2个构造函数和1个方法,我得到了3次链接错误(代码中已指出)。
//project Tester
#include "stdafx.h"
#include "CppUnitTest.h"
#include "../LifeLib/StornoTafel.h"
#include "../LifeLib/testVariables.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace Tester
{
TEST_CLASS(AggSelTest)
{
public:
LifeLib::StornoTafel stornoTafel_; // LNK2019
LifeLib::StornoTafel *stornoTafel_; // no error, but I need an instance and not a reference to proceed -> see init method
LifeLib::testVariables test_vars_; // everything is fine
TEST_METHOD_INITIALIZE(init) {
stornoTafel_ = StornoTafel(test_vars_.lapseProb); // when this line is commented out I only get the first error (see below)
}
}
}
// testVariables.h
#pragma …Run Code Online (Sandbox Code Playgroud)