"Jim Weirich" <jweirich / one.net> schrieb im Newsbeitrag
news:1041904170.8193.117.camel / traken...
> > or even more than this: maybe someone finds a way to integrate these.
> > wouldn't it be nice if the part of the test that verifies the contract
could
> > be reused in production code since it is essentially the same?  or
would
> > that bring in too much interference between test and the "real" code?
>
> Are you advocating running the unit test in the runtime code?  I'm not
> sure this makes sense.  For one thing, the unit test may modify the
> object in the course of testing it (for example, a unit test might push
> an item onto a stack to test the push method).

no, i was just wondering whether it is reasonable to make the part of the
test that verifies the contract (i.e. method signatures) accessible for
production code.  assuming we are talking about a class A, which has an
associated unit test T(A).  my question was whether it might be possible
and reasonable to extract that part of T(A) that verifies the interface of
A.  thus it could be made accessible to class B which uses A instances in
its method signatures.

but the longer i think about it the lesser i like that idea, especially
because of issue (2) you listed.  i'll have a look at you page and if i get
some new insights i let you know.  thanks for your time!

regards

    robert

> Although there is significant overlap between DbC and Unit Tests (UT),
> there are still some basic differences.  After I wrote EiffelUnit, I
> published some thoughts on DbC and Unit Testing (I put the notes at
> http://w3.one.net/~jweirich/talks/dbc-and-unittests.html).
>
> In summary ...
>
> (1) DbC assertions check every call, but only when they are enabled.
>     UT only check during the unit test run.
>
> (2) It is difficult to test for precondition correctness in UT.
>
> (3) Both UT and DbC test postconditions.  DbC expresses the
>     postcondition in general terms that must always be true.  UT are
>     written against explicit and concrete situations designed in
>     the unit test.
>
> --
> -- Jim Weirich     jweirich / one.net    http://w3.one.net/~jweirich
> ---------------------------------------------------------------------
> "Beware of bugs in the above code; I have only proved it correct,
> not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
>