Do everything in Java…

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 5 05:22:50 PST 2014


On Fri, 2014-12-05 at 11:53 +0000, Chris via Digitalmars-d wrote:
[…]
> indeed they don't catch bugs, because you only put into unit 
> tests what you know (or expect) at a given moment (just like the 
> old writefln()). The bugs I, or other people, discover later 
> would usually not be caught by unit tests simply because you 
> write for your own expectations at a given moment and don't 
> realize that there are millions of other ways to go astray. So 
> the bugs are usually due to a lack of imagination or a tunnel 
> vision at the moment of writing code. This will be reflected in 
> the unit tests as well. So why bother? You merely enshrine your 
> own restricted and circular logic in "tests". Which reminds me of 
> maths when teachers would tell us "And see, it makes perfect 
> sense!", yeah, because they laid down the rules themselves in the 
> first place.
[…]

Developers need to stop thinking "how is this code supposed to work"
when it comes to tests and start thinking "how can I break this code".
It is how testers and QA work, sadly developers all too often fail to.

This is particularly relevant for APIs where there is less likely to be
a QA team involved, and developers not looking for error cases is why so
many APIs are so broken.

One of the failings of TDD is the emphasis on correct cases,
insufficient emphasis on "how can I make this code fail". But that
doesn't mean co-development of tests and system is a bad thing. Exactly
the opposite, it is a good thing.

So on the one hand I agree with much of your analysis, but I totally
disagree with your conclusion. Unit, integration and system tests are
essential. They document the usage of code and outline the test coverage
and how well the system is likely to work. Even if a system appears to
work and yet has no tests, it is totally untrustworthy. Best response to
such code is "rm -rf *".

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141205/0ffaec93/attachment.sig>


More information about the Digitalmars-d mailing list