Re: Announcing Xrtti - Extended Runtime Type Information for C++
On May 6, 8:56 pm, Sebastian Redl <e0226...@stud3.tuwien.ac.at> wrote:
The tests of the JUnit framework (and I believe NUnit works the same) are
always functions that take no arguments and have no return value, and have
a name that starts with "test". What JUnit does is:
1) Scan a class supplied to it for functions that fulfill these
2) Execute these functions one by one.
3) Sort the results into three groups:
a) Returned -> Test succeeded.
b) Threw Framework exception -> Test failed.
c) Threw other exception -> Test failed in an unexpected way.
Specifically, the framework exceptions are thrown by the JUnit-supplied
4) Generate reports from the results.
There is nothing here that requires any artificial intelligence. It's just
boilerplate code and report generation.
I could be wrong, but it seems to me that you get to a
point where the test code itself becomes a significant fraction of
code base. If that is the case, then is it not better to spend that
mental effort on getting good form on the code so that you know it is
Test code can indeed be a significant fraction (I think in one of my
current projects it's about 2:1 in favour of functional code), but it's
worth it. Errors are hard to spot, tests are generally easy to write. Unit
tests catch errors like typos in functional strings (e.g. SQL statements).
Such typos are notoriously hard to spot - don't tell me your code never
fails to compile due to a typo. The compiler doesn't find typos in
functional strings. They are found at runtime - and the best place is unit
2:1???? Good grief! [Surely you must be joking].
Would you apply this same philosophy to your inventions if you were a
civil engineer? Would your bridges be rife with all kinds of test
devices to make sure the laws of physics have not been undermined? If
you were an electrical engineer, would there be "extra" circuitry to
make sure the "real" circuitry is behaving correctly? If you were a
mechanical engineer, would your mechanical safeguards be so
omnipresent that they would overshadow the structure being
Having a bug is one thing. Relatively massive amounts of code to
check for bugs is excessive I think. I could not possibly have so
much test code in my designs. It would get in the way of what I really
want to do - engineer the product correctly to start with. Naturally,
if this goal is achieve, then testing becomes even less of an issue
because the bugs stick out plainly (synchronization notwithstanding).
I don't think there ever was a definite statement in this thread about
putting test code in the tested class. In fact, that would be a very
So where does one put the test code if not in the class?
-Le Chaud Lapin-
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]