Why are *automated tests* so important?

*Updated* 4 November 2010: Added another reason for writing tests: Documentation


Reasons why you should write *tests* in the first place

  1. You get a bug report and want to proof when the bug is fixed
    This is a good practice before fixing bugs
  2. You implement a new feature and write a test beforehand to see when the new feature is done
  3. You want prevent regression
    Changes in your code will break other code. So you have a test around it to know if everything is still green (=OK)
    As an agile developer you change code all the time, either because
    1. You do TDD
    2. You follow the Boy scout rule (Leave the campground cleaner than you found it) and refactor your code
    3. Your client/customer changes his mind (which is even more likely)
  4. Documentation goes out of date sooner or later. Tests document how the system works and additionally they are executable

image Why don't you write tests?

 

 

Note about “documentation” vs. “tests”

  1. Documentation normally describes what the system should or might do
  2. Tests describe and make sure what the system does do

image

 

 

 

Reasons for automated tests

Automating means, those tests run on certain events on a certain machine. Typically on a build server on check in. Continuous integration follows this practice. More details on Continuous Integration in Martin Fowlers article

image

 

  1. Faster feedback
    If you have an automated test, everyone can immediately see if the latest code change, broke something
  2. Saves time
    Testing can be very boring, because it is repetitive and needs to be done very often during the day. Automated tests can take off this work from us, so we don't need to test the system ourselves. Humans are slow
  3. Safety net for code changes
    Because of this fast feedback that we get from tests, we are not afraid to change our code. Although we should "Never change a running system", with tests we can easily verify if our change broke something
  4. Testers are humans, and humans make mistakes
    A tester will decide what to test, and what not. He will maybe make mistakes during testing. All these problems can be prevented with automated tests
    tester-image7

 

image Why don't you automate your tests?

 

 

 

Upcoming
Problems with automating tests.
How to prevent people saying: it's too difficult, It takes too long, Its not my job.

Latest Posts

Popular Posts