单元测试中的错误LNK2019(CppUnitTestFramework) - C ++

时间:2018-03-29 19:19:28

标签: c++ unit-testing lnk2019 vs-unit-testing-framework

我正在尝试编写3个UnitTests。 在构建时,我收到一个错误致命错误LNK1120:1个未解析的外部。 告诉我在哪个方向搜索!

完全错误: 1> ProcessorsTests.obj:错误LNK2019:未解析的外部符号" public:静态类IProcessor * __cdecl Processor_factory :: create_processor(char)" (?create_processor @ @@ Processor_factory @@ SAPAVIProcessor @ d Z) 函数" public:void __thiscall Luxoft_TestTests :: ProcessorsTests :: ProcessorAStartProcessor_NormalString_ReversedStringReturned(void)" (?ProcessorAStartProcessor_NormalString_ReversedStringReturned @ ProcessorsTests @ @@ Luxoft_TestTests QAEXXZ)

#include "stdafx.h"
#include "CppUnitTest.h"
#include <vector>
#include "../../../../../../Data/Cygwin/home/Nik/Luxoft_Test/Luxoft_Test/IProcessor.h"
#include "../../../../../../Data/Cygwin/home/Nik/Luxoft_Test/Luxoft_Test/Factory.h"
#include "../../../../../../Data/Cygwin/home/Nik/Luxoft_Test/Luxoft_Test/Processor.h"



using namespace std;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace Luxoft_TestTests
{       
    TEST_CLASS(ProcessorsTests)
    {
    public :

        TEST_METHOD(ProcessorAStartProcessor_NormalString_ReversedStringReturned)
        {
            // arrange
            vector<string> example = { "This is normal text" };
            const vector<string> expected = { "text normal is This" };

            // action
            IProcessor* pr = Processor_factory::create_processor('A');
            const vector<string> actual = pr->Start_processor(example);
            delete pr;

            // assert
            Assert::IsTrue(equal(example.begin(), example.end(), expected.begin()));

            const char* message = "TestA passed";
            Logger::WriteMessage(message);
        }

        TEST_METHOD(ProcessorBStartProcessor_StringWithPoints_CommasReplacingPointsReturned)
        {
            // arrange
            vector<string> example = { "This.Is.Text.With.Punctuation" };
            vector<string> expected = { "This,Is,Text,With,Punctuation" };

            // action
            IProcessor* pr = Processor_factory::create_processor('B');
            vector<string> actual = pr->Start_processor(example);
            delete pr;

            // assert
            Assert::IsTrue(equal(example.begin(), example.end(), expected.begin()));

            const char* message = "TestB passed";
            Logger::WriteMessage(message);
        }

        TEST_METHOD(ProcessorCStartProcessor_StringWithSpaces_StringWithoutSpacesReturned)
        {
            // arrange
            vector<string> example = { "This is my text with spaces" };
            vector<string> expected = { "Thisismytextwithspaces" };

            // action
            IProcessor* pr = Processor_factory::create_processor('C');
            vector<string> actual = pr->Start_processor(example);
            delete pr;

            // assert
            Assert::IsTrue(equal(example.begin(), example.end(), expected.begin()));

            const char* message = "TestC passed";
            Logger::WriteMessage(message);

        }

    };
}

0 个答案:

没有答案