POV-Ray : Newsgroups : povray.off-topic : Unit tests : Re: Unit tests Server Time
4 Sep 2024 03:18:06 EDT (-0400)
  Re: Unit tests  
From: Darren New
Date: 3 Jun 2010 14:47:19
Message: <4c07f8b7$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.