12 characteristics of good, automated tests (2024)

There are several reasons for writing automated tests and writing them may seem relatively easy. However, writing “good” automated tests is significantly harder, and requires extensive experience and conscious training.

In this post, I’ve gathered some (high-level) targets that need to be checked in order for the automated tests to become good. The targets are defined in twelve characteristics and when they are fulfilled the definition of “good” automated tests is achieved.

Here are some high-level targets that might apply:

  • Tests should help us improve quality.
  • Tests should help us understand the system.
  • Tests should reduce (not increase) risk.
  • Tests should be easy to run.
  • Tests should be easy to write and maintain.
  • Tests should require minimal maintenance as the system evolves around them.

Tests should help us improve quality


1. Test as specification

If you use TDD – test-driven development or BDD – behavior-driven development (test-first development), the tests give you a way to capture what the system will do before you start building it. Thinking different scenarios through in order to turn them into tests helps us identify the areas where the requirements are ambiguous or contradictory. Such analysis clarifies the objective of the specification, which leads to a more accurate design, improving the quality of the software.

2. Defect repellent

Automated tests find bugs, but that is not the main purpose of test automation. Automated testing prevents bugs from being introduced. Think of automated tests as rejection of defects, which prevents bugs from coming back into our software after we’ve made sure it’s bug-free. When we have good and complete regression tests, there will be no bugs because the tests will point out the defects before we even check in our code.

3.Designation of defects

If the automated tests are fairly small (that is, we’re only testing a single behavior in each one), we’ll be able to pinpoint the error quickly, based on which test is failing. But to achieve that we need to write tests for all possible scenarios to cover every unit of the software. The tests must never contain ambiguities. Therefore, it is crucial that we keep the tests as small and trivial as possible (low complexity, consistent format, and testing a single behavior in each test).

Tests should help us understand the system

4. Tests as documentation

Automated tests can clearly illuminate how the code should work. They show what the result should be (it indicates the expected result of one or more statements).

If we want to know how the system does something, we can fire up the debugger, run the test, and step through the code to see how it works. The unit tests act as a form of documentation for the system.

Tests should reduce (not increase) risk

5. Tests as a safety net

Changing older code is risky because we often don’t know what we might break, and it’s also hard to know if we’ve broken something! We have to work very slowly and carefully, and do a lot of manual analysis before making any changes.

However, when working with code that has an automated test suite, we can work much faster. The tests will catch unexpected side effects of changes and let us know if we’ve broken something. In this way, the automatic tests act as a safety net that makes us dare to take chances.

6. No test risk

We must be careful not to introduce new types of problems into the system as a result of automated testing. Keep test code separate from production code to avoid creating test-specific dependencies in the system (especially important for unit test code). All test-specific code and libraries must be linked in by the test and only in the test build and in the test environment. Test dependencies and test code must never be in the final code when it is built for production.

Tests should be easy to run

There are four specific characteristics that make automated tests easy to run. With these four characteristics you can just click a button (or better yet trigger automatically) to get the valuable feedback the tests provide:

  • The tests must be fully automated so that they can be run without effort.

  • The tests must be self-evaluative so that they can detect and report errors without manual inspection.
  • The tests must be repeatable so that they can be run multiple times with the same results.
  • Each test should be independent so that it can run by itself.

7. Fully automated tests

A test that can be run without any manual intervention is a fully automated test. Fulfilling this characteristic is a prerequisite for fulfilling the others.

8. Self-evaluation

A self-assessment test can encode everything that the test needs to verify that the expected result is correct. The test only notifies us when the outcome has not been approved; as a consequence, a clean test run requires zero manual effort.

9. Repeatable tests

A repeatable test can be run over and over and still gives exactly the same results without any human intervention/analysis between runs.

Tests should be easy to write and maintain

When we change the behavior in a part of a system, we should expect a small number of tests to be affected by our modifications. One of the benefits of test automation is to make changes easily. We should therefore always strive to ensure that our tests do not do the opposite (make changes more difficult). Tests should require minimal maintenance as the system evolves around them.

10. Simple tests

Keep the focus on the tests rather than how to actually code them. This means that the tests must be simple/trivial (easy to read, easy to write and easy to maintain). We should strive to verify one condition per test by creating a separate test method for each unique combination of conditions. Each test method should test the system through a single path in the system.


11. Expressive tests

A library of helper methods that builds a domain-specific testing language allows the person writing the test code to express the concepts they want to test, without having to translate their thoughts into much more detailed code.

12. Divide the problems

Keep the test code separate from the production code (keep the structure and logic from the production code but in a parallel structure). Each test should focus on a single problem to avoid complicated and unclear tests.

Summary

There is a difference between a test and a good test, but it is often difficult to know how to define a test that is “good”. In this checklist, I shared 12 characteristics for good test automation practices, which in turn results in easy-to-write tests and proper maintenance – both factors, which are very important for a system.

12 characteristics of good, automated tests (2024)
Top Articles
Joint Network Node Operator Salaries in the United States | CareerBliss
Avalanche wants to digitize all of the world’s assets on the blockchain | TechCrunch
Canya 7 Drawer Dresser
Palm Coast Permits Online
Evil Dead Rise Showtimes Near Massena Movieplex
Tv Guide Bay Area No Cable
Pickswise the Free Sports Handicapping Service 2023
Optimal Perks Rs3
Noaa Weather Philadelphia
R/Altfeet
Thotsbook Com
Cnnfn.com Markets
Belle Delphine Boobs
Sony E 18-200mm F3.5-6.3 OSS LE Review
Dallas Cowboys On Sirius Xm Radio
Does Breckie Hill Have An Only Fans – Repeat Replay
Google Flights Missoula
Cocaine Bear Showtimes Near Regal Opry Mills
Drago Funeral Home & Cremation Services Obituaries
Little Caesars 92Nd And Pecos
Schedule An Oil Change At Walmart
The Old Way Showtimes Near Regency Theatres Granada Hills
Engineering Beauties Chapter 1
What Are The Symptoms Of A Bad Solenoid Pack E4od?
TeamNet | Agilio Software
Haunted Mansion Showtimes Near Epic Theatres Of West Volusia
Shoe Station Store Locator
Powerschool Mcvsd
Dei Ebill
Maisons près d'une ville - Štanga - Location de vacances à proximité d'une ville - Štanga | Résultats 201
Mercedes W204 Belt Diagram
2487872771
Why Are The French So Google Feud Answers
Indiana Jones 5 Showtimes Near Jamaica Multiplex Cinemas
Siskiyou Co Craigslist
The Wichita Beacon from Wichita, Kansas
Merge Dragons Totem Grid
What Does Code 898 Mean On Irs Transcript
Lovein Funeral Obits
Aurora Il Back Pages
10 Types of Funeral Services, Ceremonies, and Events » US Urns Online
20 Mr. Miyagi Inspirational Quotes For Wisdom
Xre 00251
Conan Exiles Colored Crystal
Ratchet And Clank Tools Of Destruction Rpcs3 Freeze
Ajpw Sugar Glider Worth
552 Bus Schedule To Atlantic City
Underground Weather Tropical
What Is The Gcf Of 44J5K4 And 121J2K6
8663831604
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6314

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.