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.

3 comments:

Anonymous said...

Like!

Unknown said...

Hi Peter,

>>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

This is a nice point and a good reason to have a Automated Tests ! However, when you say "Automated Tests" here, do you consider the Unit Tests or the Functional Automation Tests ?

Cheers,
Anit

Peter Gfader said...

Hi Anit

I think all tests should be automated as much as possible.

Actually everything should be automated as much as possible. What do we have machines for???

Post a Comment

Latest Posts

Popular Posts