All resources
ArticleAutomation EngineeringTest AutomationTest CasesQA ProcessBest Practices

How to Write Test Cases from an Automation Perspective

June 17, 20253 min readBy Tihomir Vékony

How to Write Test Cases from an Automation Perspective

Why This Matters

In many projects, test cases are written with manual QA workflows in mind. However, automated tests require a different mindset due to automation executing line by line, and halting on any failed assertion. This means poorly structured or overly complex test cases can result in brittle, hard-to-maintain automation.

This guide outlines how to structure and write automation-friendly test cases that are reliable, maintainable, and aligned with automated execution behavior.

Types of Automation Test Cases

We categorize automated test cases into two main types.

Atomic Tests

Isolated validations of a single functionality.

Purpose

Atomic Tests validate one specific feature in isolation. They are straightforward, limited in scope, and have exactly one test condition. These tests help pinpoint exactly where a failure has occurred.

Structure

  • Preconditions (e.g., user account exists)
  • Navigation steps to reach the module under test
  • Setup/retrieval of necessary data
  • Assertion/validation

Example

  1. Log in as user X
  2. Navigate to the product page
  3. Add a product to the cart
  4. Validate that the product price is X

Journey Tests

End-to-end user flows that validate multiple conditions.

Purpose

Journey Tests follow a full user interaction flow through the system, verifying correctness at several stages. They cover more complex scenarios and test integrations between modules.

Structure

  • Preconditions
  • Step-by-step journey through the UI
  • Assertions at meaningful points
  • End of journey validations

Example

  1. Log in as user X → Validate that login was successful
  2. Add a product to the cart → Validate that the product is visible in the cart
  3. Proceed to checkout → Validate product name and price on checkout page
  4. Confirm the purchase → Validate that the product appears on the order confirmation page

Best Practices for Writing Automation-Friendly Test Cases

Separate Tests Into Logical Units

Avoid writing one test case that checks multiple unrelated behaviors.

❌ Bad:

Test Case 1:

  • Log in as user X, Y, and Z in the same test

✅ Good:

Test Case 1:

  • Log in as user X

Test Case 2:

  • Log in as user Y

Test Case 3:

  • Log in as user Z

Make Each Test Step a Single Action

Avoid bundling multiple actions in one step. This improves readability and makes debugging easier.

❌ Bad:

  1. Log in, navigate to page N, consult table F
  2. Validate data

✅ Good:

  1. Log in
  2. Navigate to page N
  3. Consult table F
  4. Validate that data in table F matches expected results

Write Self-Contained Test Cases

Test cases should not rely on prior context or tribal knowledge. Anyone — including new team members or product stakeholders — should be able to follow and execute the test.

❌ Bad:

Validate that the data on the page is correct

✅ Good:

Validate that the page contains:

  • A blue button with text "Buy Now"
  • A label showing "Total: $49.99"

Being explicit ensures clarity and reduces the need for clarification.

Use Parametrization Where Applicable

If the same test flow is repeated with different input data, use parameterized test cases to keep things concise and scalable.

Example:

Preconditions:

Users X, Y, and Z exist

Steps:

  1. Log in as [parameter: user]
  2. Validate that [parameter: user] is logged in

This reduces duplication and makes maintenance easier.

Summary

  • Prefer Atomic Tests for isolated functionality and Journey Tests for full workflows.
  • Keep tests simple, focused, and reproducible.
  • Ensure test cases are automation-friendly: one failure = one problem.
  • Be descriptive — don't assume shared context.