Re: TDD doesn't suck
- From: "Phlip" <phlipcpp@xxxxxxxxx>
- Date: Wed, 16 Aug 2006 17:14:26 GMT
goose wrote:
How am I misinterpreting it? The "OTOH" means
"On the other hand" so it would mean that TDD does /not/
require you to brute force test. Sorry if that wasn't
clear.
Sorry; I overreacted to "brute-force". We might be nearing alignment. Here's
why I overreacted:
The tests are simple but not brute-force. Let's reserve "brute-force" to
mean "stepping through every combination, in order". The worst kind of
algorithm. TDD test cases are "design constraints"; they are not about the
same things as Unit Tests are about.
One myth of TDD is "write a test case that fails in such a way that only the
correct code can pass it". That's wrong, but some TDD tutorials talk like
that.
Here's some TDD:
TEST(CheckSucceedsOnTrue)
{
bool failure = true;
{
RecordingReporter reporter;
UnitTest::TestResults testResults_(&reporter);
CHECK (true);
failure = (testResults_.GetFailureCount() > 0);
}
CHECK (!failure);
}
That's from UnitTest++. It checks that the CHECK(macro); increments the
FailureCount value. The testResults_ thing is a copy of the infrastructure
that the TEST() macro itself uses. This is one of the test cases used to
build UnitTest++ itself.
Note that it doesn't even check the resulting count is 1. It could. But it's
not a Unit Test, and it doesn't even pretend to provide coverage.
None of the test cases are any more complex than that. Some have more lines,
but none have more logic.
You would find adding a bug to UnitTest++'s core, then passing all the
tests, very hard.
Maybe I do have the wrong end of the stick wrt TDD,
please, by all means clear up my misconceptions.
1. Write a minimal test for proposed functionality.
2. Do a minimal number of edits to make the test fail
for the correct reasons.
<compile>
compile and test.
3. Implement enough of the functionality to make the
test pass, undoing any edits on errors.
<compile>
4. Refactor and neaten if need be.
5. Lather, Rinse and Repeat.
Okay, I'll calm down now.
I hope that I at least got the basic gist of it, if not
all of the finer detail. Now, compare that with my
typical lisp cycle:
1. Write the function (say .. "foo").
2. If, while writing the function, I decide that
non-existent functionality is needed and therefore
a new function is needed (say ... "bar"), I go ahead
and write a call to the new function.
3. I evaluate foo and get an error (bar not written yet)
so I go back to step 1 writing bar or get an error
(a bug) which will then get attention.
4. Once foo evals cleanly, I try a few more evals
and then move on, back at step 1 for the next
piece of functionality.
The big difference between the two seems to be that
TDD is test-first and I do write-first.
The other big difference is nothing stops you. The goal is the ability to
write Foo(), now, and ignore Bar(), written long ago. The more you can
ignore, the faster you go. But writing Foo() might require changing code
that Bar() depends on. Without test suites, Bar() might get a quiet bug.
Worse, Bar() might get wedged so _another_ change would make it express a
bug. In that situation, Foo() is not implicated, and you must debug Bar() to
seek the cause.
I /still/ consider TDD moot in a lisp environment,
and I would *really* like to hear an experienced
lisper tell me how to make TDD useful in a lisp
environment.
I passed this question to the TDD mailing list. But you should trust your
own USENET proficiency enough to ask comp.lang.lisp. Not all TDD posts start
flamewars.
They used to start them all the time on news:comp.object , but they don't
seem to any more. For some strange reason...
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
.
- References:
- Re: TDD doesn't suck
- From: Phlip
- Re: TDD doesn't suck
- From: goose
- Re: TDD doesn't suck
- From: Phlip
- Re: TDD doesn't suck
- From: goose
- Re: TDD doesn't suck
- From: Phlip
- Re: TDD doesn't suck
- From: Rob Thorpe
- Re: TDD doesn't suck
- From: goose
- Re: TDD doesn't suck
- From: Phlip
- Re: TDD doesn't suck
- From: goose
- Re: TDD doesn't suck
- Prev by Date: Advice on data structure for scheduled events
- Next by Date: Re: Advice on data structure for scheduled events
- Previous by thread: Re: TDD doesn't suck
- Next by thread: Re: TDD doesn't suck
- Index(es):
Relevant Pages
|