Home > Archive > Extreme Programming > August 2004 > How to compile Cppunit test cases?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to compile Cppunit test cases?
|
|
| Markus Dehmann 2004-08-26, 8:57 pm |
| All Cppunit examples in the cppunit/examples/ directory have very long
and complex Makefiles with them. Is that necessary?
If I want to use my own Cppunit test cases in my project, I certainly
cannot write these complex Makefiles. I also don't use configure.
So, how can I compile Cppunit test cases, just using simple g++
commands?
I tried the following. It compiles, but does not run correctly:
bash-2.05b$ g++ -c ExampleTestCase.cpp
bash-2.05b$ g++ -c Main.cpp
bash-2.05b$ g++ Main.o ExampleTestCase.o -lcppunit -ldl
/usr/local/lib/libcppunit-1.10.so.2
bash-2.05b$ ./a.out
ExampleTestCase::example : assertion
ExampleTestCase::anotherExample : assertion
ExampleTestCase::binaryExample : assertion
ExampleTestCase::testAdd : assertion
ExampleTestCase::testDivideByZeroFloatin
g point exception
But the correct test case run would be:
ExampleTestCase::example : assertion
ExampleTestCase::anotherExample : assertion
ExampleTestCase::binaryExample : assertion
ExampleTestCase::testAdd : assertion
ExampleTestCase::testDivideByZero : OK
ExampleTestCase::testEquals : assertion
ExampleTestCase.cpp:7:Assertion
[...]
Failures !!!
Run: 6 Failure total: 5 Failures: 5 Errors: 0
So, how can I compile these test cases in a simple way, without using
13KB Makefiles, and make them run correctly?
Thanks!
| |
|
| Markus Dehmann wrote:
> All Cppunit examples in the cppunit/examples/ directory have very long
> and complex Makefiles with them. Is that necessary?
Try this:
http://www.xpsd.org/cgi-bin/wiki?NanoCppUnit
It has a stray OutputDebugString in it, but other than that it's completely
portable, and uses a TEST_() macro for the test collector pattern in C++.
The problem with CppUnit is this: SUnit -> JUnit -> CppUnit. Each time they
ported, they did not reconceptualize based on the target platform's balances
and needs. So a rewrite of the raw TDD concept, in one header file with a
few lines of code, can get you coding faster than all that excess.
What CppUnit provides is a results object, and pluggable test runners. TDD
doesn't need them, because if a test fails unexpectedly you only need to
inspect the situation, then use Undo until things get better.
--
Phlip
http://industrialxp.org/community/b...tUserInterfaces
|
|
|
|
|