AI, robotics and crypto, in context Deutsch

Automation

Test Automation: Deciding Which Tests Machines Should Run

Turning every manual test script into code produces a slow, fragile suite. How to pick the checks worth automating, at which level to run them, and what testers still do better than any script.

Test Automation: Deciding Which Tests Machines Should Run

A software team at a regional bank decides to automate its regression testing. It takes the two hundred manual test scripts its testers have used for years and turns each one into an automated test that clicks through the web application. Six months later the suite runs for most of the night, fails a few times a week for unclear reasons and still misses bugs that customers find.

Nothing was wrong with the tools. The mistake was the selection. Manual test scripts were written for people, who notice odd things along the way, and for a time when testing happened once before each release. Copying them into code kept their length and their focus on the screen, but lost the human attention that made them work.

Good test automation starts with a different question: which checks should a machine run, at which level and how often? Answering it well matters more than the choice of tool.

What machines check well and what they miss

Automated tests are good at repetition and precision. They run the same steps the same way every time, with any number of data combinations, and they never get bored on the fortieth run. They are ideal for confirming that something that worked yesterday still works today.

They are poor at noticing what they were not told to look for. A script that checks an account balance will not notice that the page now takes ten seconds to load, that a label covers a button or that a new workflow confuses users. Those observations come from people who use the software with open eyes.

Choosing candidates

Teams that get value from automation tend to rate each candidate on a few simple factors before writing any code:

  • How often the check needs to run. A check run on every code change is worth far more automated than one run twice a year.
  • How stable the feature is. Automating a screen that is redesigned every month creates maintenance work, not safety.
  • How much damage a failure would cause. Payments, logins and calculations deserve more automated coverage than a help page.
  • Whether the expected result is clear. A test needs an answer it can compare against, such as a total or a status.
  • How hard the test data is to prepare. Some checks need accounts, orders or dates in a particular state, and that setup can cost more than the test.
  • How long the check takes by hand. Long, repetitive manual checks with many data variations are strong candidates.

A check that scores high on frequency, stability and risk is a clear yes. One that scores low on stability or has no clear expected result usually stays manual for now.

The scoring does not need to be precise. Its purpose is to force a short conversation about each candidate before anyone writes code, and to record why some checks were left out. That record helps when someone later asks why a particular area has no automated tests.

Test at the lowest level that can catch the bug

Where a test runs matters as much as what it checks. Tests at the code level, often called unit tests, run in milliseconds and point to the exact function that broke. Tests against an application's programming interface check business rules without a browser. End-to-end tests drive the real user interface and confirm that everything fits together, but they are the slowest and the most fragile.

A common rule of thumb is a pyramid: many small code-level tests, a solid layer of interface tests and only a few end-to-end tests for the most important user journeys. In the bank example, most of the two hundred scripts were really checking calculation rules and input validation. Those checks belong lower down, where they run faster and break less often.

A test that clicks through five screens to check one calculation is paying for four screens it does not need.

Where the payoff really comes from

Test automation is often sold as a way to need fewer testers. In practice the savings in testing hours are modest once maintenance is counted. The larger gain is speed of feedback. When a developer learns within minutes that a change broke the interest calculation, the fix takes minutes too. When the same bug surfaces weeks later, it costs far more to trace.

Fast feedback is what makes frequent releases safe. A team that runs its key checks automatically on every change can ship small updates often, instead of large risky ones rarely. That benefit depends on the suite being fast and trustworthy, which is another reason to keep it lean.

Maintenance is the cost that business cases tend to forget. Every change to the application can require changes to tests, and a large set of end-to-end tests can keep a person busy for much of the week. Counting that effort honestly is part of deciding what to automate.

What stays with people

Some testing work does not automate well, and trying usually wastes effort. Exploratory testing, where a tester probes a feature with curiosity and no fixed script, finds the problems nobody predicted. Judging usability, wording and whether a workflow makes sense also needs people. So does testing a new feature while its design is still changing.

Automation changes the tester's job rather than ending it. Testers decide what deserves automated coverage, design good checks, read failure reports and spend more of their time on exploratory work. Teams that treat testers only as script writers tend to lose that judgment.

Keeping the suite honest

A test suite grows easily and shrinks rarely. Without care it fills with duplicates, tests of retired features and checks that fail so often that everyone ignores them. Regular review helps: delete tests that no longer protect anything, move slow checks to a lower level and fix or remove unreliable ones quickly.

Coverage figures can mislead here. A high share of code touched by tests says little about whether the risky parts are checked well. A short list of the functions that would hurt most if they failed, each with named tests that protect it, is often a better guide than a percentage.

Questions and answers

Should we automate all our manual test cases?

Usually not. Manual test cases were written for people and often contain long sequences that are slow and fragile as code. It is better to choose by frequency, stability and risk, and to rewrite the chosen checks at the lowest level that can catch the problem.

When is the right time to start test automation in a project?

Code-level tests are best written alongside the code, because that is when they are cheapest. End-to-end tests are better added once the main user journeys and screens have settled. Starting them too early means rewriting them with every redesign.

Who should write automated tests, developers or testers?

Both, at different levels. Developers usually write code-level and many interface tests as part of their work. Testers often design end-to-end checks and decide which risks need coverage. What matters is shared ownership, so that a failing test is everyone's problem.

How do we measure whether test automation is worth it?

Look at how quickly the team learns about defects, how many bugs reach customers, how often releases happen and how much time goes into maintaining the suite. The number of automated tests says little on its own. A smaller, faster suite that catches important bugs is worth more than a large one nobody trusts.

Can AI write our automated tests?

AI tools can suggest test code and test data, which speeds up routine work. They still need a person to decide what is worth testing and to confirm that the expected results are correct. A generated test that asserts the wrong answer gives false confidence.