使用cpputest的tdd会在ubuntu 14.04中产生错误

时间:2015-07-01 23:46:33

标签: cpputest

我正在尝试学习cpputest,所以去了cpputest手册并在我的ubuntu 14.04lts笔记本电脑中复制了下面的代码,并试图制作。我是新手制作文件,我遇到了一堆错误 - 我怎样才能纠正我的代码?

#include "CppUTest/TestHarness.h"
#include "CppUTest/TestOutput.h"

TEST_GROUP(FirstTestGroup)
{
};

TEST(FirstTestGroup, FirstTest)
{
    FAIL("Fail me!");
}

TEST(FirstTestGroup, SecondTest)
{
   STRCMP_EQUAL("hello", "world");
   LONGS_EQUAL(1, 2);
   CHECK(false);
}

那是test.cpp,我的主要内容如下test_main.cpp

#include "CppUTest/CommandLineTestRunner.h"

int main(int argc, char** argv)
{
   return CommandLineTestRunner::RunAllTests(argc, argv);
}

make文件是:

all: test
export CPPUTEST_HOME=/usr/share/cpputest
CPPFLAGS += -I$(CPPUTEST_HOME)/include 
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt

test: test_main.o test.o
    g++ -o mytest test.o test_main.o
test_main.o: test_main.cpp 
    g++ -c test_main.cpp $(CPPFLAGS) 
test.o: test.cpp 
    g++ -c test.cpp  $(CPPFLAGS) $(LD_LIBRARIES)
    #g++ -C -o test_main.o test_main.cpp test.o test.cpp $(CPPFLAGS) 
    #g++ -o mytest tet_main.o test.o $(LD_LIBRARIES)

clean:
    rm -f *.o mytest

当我说make 我收到一堆错误。

请在这方面帮助我

1 个答案:

答案 0 :(得分:2)

I changed the my makefile as follows: after the changes it worked

all: mytest
export CPPUTEST_HOME=/usr/local
CPPFLAGS += -I$(CPPUTEST_HOME)/include 
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt

mytest: test_main.o test.o
    g++ -g -o mytest test.o test_main.o $(LD_LIBRARIES)
test_main.o: test_main.cpp 
    g++ -g $(CPPFLAGS) -c test_main.cpp
test.o: test.cpp 
    g++ -g $(CPPFLAGS) -c test.cpp
clean:
    rm -f *.o mytest