Women in Technology

Hear us Roar



Article:
  Top 12 Reasons to Write Unit Tests
Subject:   Testing is a wrong way ...
Date:   2003-04-09 06:30:58
From:   anonymous2
By tests you can only prove the existence of errors, not their absence.
Full Threads Oldest First

Showing messages 1 through 5 of 5.

  • Eric M. Burke photo Testing is a wrong way ...
    2003-04-09 06:42:56  Eric M. Burke | O'Reilly Author [View]

    We never said that tests prove the absence of errors. I will say that tests reduce the number of errors, improve code quality, and help avoid regressions - i.e. re-introducing bugs that were previously fixed.

    A blanket statement like "Testing is a wrong way" is incredibly negative and is not constructive. What is the alternative? No tests, as is done in many organizations? I don't think so.

    Tests are one piece of a much bigger puzzle - they don't solve every problem, but you'll have a lot more problems if you don't bother to write tests.
    • Testing is a wrong way ...
      2003-04-29 05:57:18  anonymous2 [View]

      Yes, it's true that testing does not guarantee perfect code; yet it does provide a marginal benefit ("marginal" meaning that you spend a little bit of effort testing, and you get a little bit of benefit in return). And a marginal benefit is definitely worth something!

      Unfortunately, the word "test" does suggest perfection to me... I wish for a better word, that conveys the idea of marginal benefit.

      For some reason, when I write test code, it's very easy for me to fall into the trap of trying to make it perfect. Perhaps this is because of the problem of "false alarms" - that is, your test code has a bug in it, which makes it think your app code has a bug in it, when it doesn't really have a bug in it.

      If you test code is imperfect in this particular way, it can really waste a lot of time.

      BTW: While testing is obviously central to the XP canon, it doesn't seem to follow the same philophy, because of the need for perfection in this sense; and because you cannot write tests in an XP way (ie they have to work correctly and completely for them to be any use).

      Regression bugs are pretty rare - the vast majority of bugs are new bugs whose cause you hadn't thought of before. In my experience, it is as miraculous as it is rare whenever an automated test actually catches a new bug.

      For these reasons, they often aren't worth the effort for the marginal benefit they provide.
      Of course, if you create a lot of regression bugs for some reason (eg interactions between components written by different people), then the marginal benefit is much greater.
    • Testing is a wrong way ...
      2003-04-29 05:55:06  anonymous2 [View]

      Yes, it's true that testing does not guarantee perfect code; yet it does provide a marginal benefit ("marginal" meaning that you spend a little bit of effort testing, and you get a little bit of benefit in return). And a marginal benefit is definitely worth something!

      Unfortunately, the word "test" does suggest perfection to me... I wish for a better word, that conveys the idea of marginal benefit.

      For some reason, when I write test code, it's very easy for me to fall into the trap of trying to make it perfect. Perhaps this is because of the problem of "false alarms" - that is, your test code has a bug in it, which makes it think your app code has a bug in it, when it doesn't really have a bug in it.

      If you test code is imperfect in this particular way, it can really waste a lot of time.

      BTW: While testing is obviously central to the XP canon, it doesn't seem to follow the same philophy, because of the need for perfection in this sense; and because you cannot write tests in an XP way (ie they have to work correctly and completely for them to be any use).
    • Testing is a wrong way ...
      2003-04-09 07:41:50  anonymous2 [View]

      The solution is verification and analysis. As e.g. an algorithm, which was modelled with a petri net, can be examined for characteristics as deadlock, livelock, buffer capacity, ...
      Testing represents a optimistic procedure: develop first and then test. A better way would be the following: permit only methods for development, which produce guaranteed (mathematically founded) correct algorithms - see petri nets

      Yours sincerely,
      Gabriel
      • Testing is a solution, not THE solution
        2003-04-09 09:57:29  anonymous2 [View]

        That's nice, but I can guarantee any software house that only implements provable algorithms will get crushed in the marketplace by a company that uses agile methodologies to produce software that is "good enough" because the agile company will ship first. Ship Or Die.

        In a risk-return analysis, test-first design will beat mathematical analysis in all but a few niches.

        Also, you can't be competetive in the marketplace if you have to re-prove your code every time you have to adapt your code for a new feature, or refactoring.