Wednesday, July 13, 2016

cpputest

I spent several hours figuring out how to run cpputest in Ubuntu. I searched several websites, but they were not helpful. You can imagine the agony that I went through.

Finally, I came across this stackoverflow question. Thank you, pradeep (the author of the question (and also the answer)).

Well, first you need to install CppUTest in Ubuntu:

% sudo apt-get install cpputest

After that, create the files: test.cpp, test_main.cpp, and makefile

For the makefile file, be sure to use tab indentations and not spaces.

After creating the files:

kuyu@castor-ub:~/dkuyu/practice/cpp/cpputest/hello$ make 
g++ -g -I/usr/local/include  -c test_main.cpp
g++ -g -I/usr/local/include  -c test.cpp
g++ -g -o mytest test.o test_main.o -L/usr/local/lib -lCppUTest -lCppUTestExt
kuyu@castor-ub:~/dkuyu/practice/cpp/cpputest/hello$ ./mytest 

test.cpp:15: error: Failure in TEST(FirstTestGroup, SecondTest)
expected <hello>
but was  <world>
difference starts at position 0 at: <          world     >
                                              ^

.
test.cpp:10: error: Failure in TEST(FirstTestGroup, FirstTest)
Fail me!

.
Errors (2 failures, 2 tests, 2 ran, 1 checks, 0 ignored, 0 filtered out, 1 ms)

kuyu@castor-ub:~/dkuyu/practice/cpp/cpputest/hello$ 

It finally ran.

No comments:

Post a Comment