[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: asserting in code vs unit tests

John Carter

3/6/2006 12:23:00 AM

1 Answer

chiaro scuro

3/6/2006 12:33:00 AM

0

Interesting. Could you expand on "recommends quite sanely that you
should only spin a class if and only if you have an invariant to
protect"? it feels right but I am not sure I get it completely.

Another thing.. one big problems that I have with assertions is
duplication. Do you assert any method? do you assert on class public
methods? It's very to sprinkle the same assertions all over the place.

On 3/6/06, John Carter <john.carter@tait.co.nz> wrote:
> Unit Tests and DbC assertions are complementary, not exclusive. I always
> do both.
>
> I tend to put the "post condition" assertions in the Unit Tests and
> invariant and pre-condition assertions in the code.
>
> Why?
>
> 1) The pre-condition assertions are "tests of the tests". Test's are code
> too, therefore have bugs.
>
> 2) Post-conditions are effectively the asserts found in the unit test. ie