|
![](/i/fill.gif) |
Orchid XP v8 wrote:
> Darren New wrote:
>> Thinking on it a bit, it sounds like unit testing is just a way to add
>> Eiffel-style programming-by-contract to your code without any actual
>> language support for it.
>
> I thought the term was "design by contract"?
Yeah. Brain-O.
> Well whatever. Contracts seem like a nice idea; you make it clear who's
> supposed to check for error conditions - whether it's supposed to be the
> caller or the callee. And you can enforce it by enabling checks at
> runtime. Having said that, I don't recall using it much myself in my own
> code.
Yep. Every time you use "assert" to check your inputs, you're doing that.
Except with minimal language assistance.
Unit testing just takes those asserts outside the function.
> On top of that, any kind of testing is going to be easier if a
> function's output depends only on its current inputs...
Yep. The problem with "unit testing" per se is that it only tests a unit. It
doesn't test anything except the invariants of the unit you're testing.
--
Darren New, San Diego CA, USA (PST)
Eiffel - The language that lets you specify exactly
that the code does what you think it does, even if
it doesn't do what you wanted.
Post a reply to this message
|
![](/i/fill.gif) |