Skip to content
wannacode

Why and what to automate

In short: An automated test is a program that runs the system and compares the result, with no person involved. It pays off for rules that rarely change, are checked on every change and cost money when they break. It does not pay off for a one-off check, for a screen that still changes, or for anything that needs human judgment. Its real cost is maintenance.

Problem

Two days of manual tests every week

The shop releases a new version every Friday. Before every release QA goes through 120 test cases by hand: delivery, the cart, promo codes, returns. It takes two days.

Last week there was a public holiday, and there was time for 80. The 40 that were skipped were "the old ones, they do not break". On Monday a customer paid for delivery on an order of exactly 50.00 €. The change was in the promo code logic, and it broke the delivery boundary.

The idea

Test automation

Test automation is a program that runs the system, gives it the input from the test case and compares the result with the expected one. No person involved, and the same on every run.

What it gives you:

  • regression becomes cheap. 120 cases run in minutes, on every change, not over two days once a week;
  • the same every time. A program does not get tired at case 80 and does not skip "the old ones";
  • fast feedback. The programmer learns that the boundary is broken five minutes later, while they still remember what they touched;
  • living documentation runs. The scenarios from the Gherkin module stop being text in a folder: they become a check that passes or fails.

Automation does not invent tests. A person still writes the test case. Automation repeats it.

The idea

What is worth it and what is not

An automated test is paid for once when it is written and then on every change. So it is worth it when it runs many times and changes rarely.

It is worth it for:

  • rules that do not change every week: delivery, the cart limit, discounts;
  • checks before every release (regression);
  • many examples of the same rule: ten amounts around the boundary;
  • places where a bug costs money or trust.

It is not worth it (or not yet) for:

  • a one-off check: a data migration that happens once;
  • a screen the designer still changes every day;
  • anything that needs judgment: is the form clear, does it look right, is it convenient. That is usability, and people look at it;
  • exploratory testing: there the question is invented while you test.

Try it

Automate or not?

1. The free delivery rule: it is checked before every release, and there is a release every week.
2. The new home page: the designer changes it every day this week.
3. Do older customers understand the returns form?
4. Migrating the old orders to the new database: it happens once, on Saturday night.

The idea

The risks

Automation often fails not because of the tool but because of the expectations:

  • "It will find all the defects." A test checks only what someone thought of. If nobody thought of the empty cart, automation will not check it, however many times it runs. The mutants in the Gherkin module slipped through in exactly this way.
  • Underestimated maintenance. Tests are code. When the threshold becomes 60 €, the scenarios, the steps and the tests change. If nobody maintains them, a month later half of them are red and the team stops looking.
  • A test nobody trusts. If a test fails "sometimes", people start running it again until it passes. Then a real failure slips through too.
  • Everything through the screen. Tests through the browser are slow and break when a button moves. Most checks belong further down.
  • The tool as the goal. "We bought a tool" is not a strategy. First comes what has to be checked, then what to check it with.
More precisely, if you are curious

ISTQB CTFL v4.0.1 covers tools in chapter 6. Section 6.2 lists the benefits, among them less repetitive manual work, more consistency, faster feedback and more time for new tests, and the risks, among them unrealistic expectations, inaccurate estimates of time and cost (including maintenance), using a tool where manual testing is more suitable, relying on a tool too much and ignoring human critical thinking, and dependence on the tool vendor or on open-source software that may be abandoned.

For those who will write automation for a living, ISTQB has a separate advanced certificate: CTAL-TAE (Test Automation Engineering). It is about the architecture of automation and is not part of this course.

The idea

Which level for which check

The pyramid from the module on levels says how many tests on which level. In automation it becomes concrete:

  • scenarios (the next lesson) check the rule in the words of the business. They are the living documentation;
  • component tests check one piece of code, fast and with many examples: ten amounts around the boundary in milliseconds;
  • API tests send real requests to the shop's server, without a browser;
  • UI tests open a browser and click like the customer. Only a few, for the paths that must not break.

In this module the rule stays the same throughout: delivery is free from 50.00 € inclusive, otherwise it is 4.90 €, and an empty cart is refused. You will see it automated on every level, in Java, C#, Python and JavaScript, and you will see which test catches which bug.

Here you need to be able to read code in one of the four languages. What you need is in the programming course, up to the module "Real-world programs": classes, exceptions and component tests.

Try it

The path of one rule

Put the path of the delivery rule in order, from the agreement to the report.

  1. The rule is checked with component tests too
  2. The scenario is connected to the code through steps
  3. The tests run on every change to the code
  4. The rule is agreed and written down as a scenario
  5. The report says what failed and why

Exercise

An automation plan

1. What first and why. The shop is just starting with automation.

1. Which of these four is best to automate first?
2. The team automates 300 tests in a week. A month later half of them are red and nobody looks at them. Which risk has come true?
3. The manager says: "We have automation, we do not need testers any more." What are they missing?

Test

Check yourself

1. What is an automated test?
2. What makes a rule a good candidate for automation?
3. What is the biggest ongoing cost of automation?
4. Where in the pyramid do most automated tests go?

Made by Ivo Gergov as part of Evo Tech's campaign for accessible programming education ·