AMA: What should be the ideal length of an automated test script?

Sajitha Pathirana
3 min readAug 10, 2022

That’s a tricky question to answer!

Keeping the test short or long depends on many factors like the expectations of the testing, the scope of the automation, the complexity of the application and the domain, your experience, and so on.

Photo by patricia serna on Unsplash

Keeping a test short vs long has its own pros and cons.

To keep this answer short I will highlight major points.

  • If a test is left short, which means validating one point, the single test will be fast, stable, and easy to narrow down any issues. However, on the other hand, we will have to maintain a large number of tests to increase the coverage, and could be challenging to maintain the test bed.
  • If a test is long, covering many scenarios, the number of tests we may need to increase the coverage would be less, easy to maintain the test bed. The disadvantage would be if an issue occurred in the middle of the script, the rest of the script will fail. Due to this, a minor failure can stop more important parts of the test from executing.

As automation engineers, we need to focus on time, ROI, and maintainability.

My suggestion is a mix of both long and short tests should be occupied to retain the balance of time and ROI.

One other important aspect we could adopt is the use of soft assertions for verification where the latter part is not harmed due to failures.

One example would be, if you are doing validation for the login with usernames and passwords, you could use soft assertions to validate each scenario and assert all at the end of the test. With this, each and every combination is validated as a single test and it will execute all the scenarios irrespective of failures.

You can further read on soft assertions

🤝 If you enjoy reading stories like this and you want to support me, why not consider signing up for a Medium membership? It will only cost you $5 a month — and…

Sajitha Pathirana

A Test automation enthusiast, passionate to help the teams to enhance their testing journey with his decade of experience in the field.