Re: unit testing C++ code from perl
- From: Phlip <phlip2005@xxxxxxxxxxxx>
- Date: Fri, 07 Jul 2006 14:05:16 GMT
Nick Keighley wrote:
do you have to read a book to understand any of this?
Unfortunately yes.
Beck's "Test Driven Development"? I was meaning to read it.
+ the aftermarket books - /Unit Test Frameworks/ by Paul Hamill,
/Pragmatic Starter Kit/ by the Pragmatic Programmers, etc.
I'll take a look at CppUnit*
That is all but repudiated.
In the beginning, SmalltalkUnit invented the framework, including a system
to make lists of failing test cases, including a system to pick which
tests to run, etc.
Then Kent Beck et al ported that to Java, as a straight translation.
Then Mike Feathers ported JUnit to CppUnit, as a straight translation.
This lost the Test Collector pattern, so you must write the name of each
test case like 3 times to put it in the list of tests. That irritation is
symbolic of CppUnit's general heaviness.
Read up on CppUnit, and try a sample project, to learn about test-first in
C++. Then use a lighter test rig.
TEST(whatever)
{
CHECK(false);
}
so macros arn't evil :-)
The C++ community has too many people eager to prove they read /Effective
C++/ and snarl at them. (Oh, and it also has too many people eager to
abuse them, too...)
Mature programmers know to use macros for the three things that nothing
else can do:
- conditional compilation
- stringerization
- token pasting
The TEST() macro qualifies for all three.
ok. I hate comments like that. I was arguing each *class* should have
1..few
lines saying what it's for. It's not always easy to tell what is for use
of
a user of a package and what is purely internal. I'm a hater of
unnecessary
and unhelpful comments, but *no* comments!!
The test cases that treat entire test suites (classes) are exemplary.
I just looked at a file I created yesterday. It started with a one line
title
"a foo class for refrobnicating", Three lines explaining in more detail
what
it did and then an example of usage. I wasn't trying to flood with
comments
it just seemed natural.
That's fine.
Treat all comments as a failed opportunity to improve the code's
clarity.
well we might have to agree to differ on this one...
For a class, C++ itself failed. Classes are hard to specify! So comment
them...
--
Phlip
.
- References:
- Re: unit testing C++ code from perl
- From: Tom Plunket
- Re: unit testing C++ code from perl
- From: Nick Keighley
- Re: unit testing C++ code from perl
- From: Phlip
- Re: unit testing C++ code from perl
- From: Phlip
- Re: unit testing C++ code from perl
- From: Nick Keighley
- Re: unit testing C++ code from perl
- From: Phlip
- Re: unit testing C++ code from perl
- From: Nick Keighley
- Re: unit testing C++ code from perl
- Prev by Date: Re: unit testing C++ code from perl
- Next by Date: Re: How to calculate largest number in sub-range?
- Previous by thread: Re: unit testing C++ code from perl
- Next by thread: Re: unit testing C++ code from perl
- Index(es):