Testing PatternsStructuring Your Tests

Structuring Your Tests

A well-structured test project is crucial for long-term maintainability, easy navigation, and efficient test execution. This guide covers the best practices for organizing your tests in ReAPI.

1. Organize with Folders and Tags

ReAPI provides two primary tools for organizing your test cases: folders and tags.

Folders for Structural Grouping

Folders are the main way to group related test cases. A logical folder structure makes your project intuitive to browse and manage.

Common Folder Patterns:

  • By Feature / Module (Recommended): This is the most common and effective pattern. Group tests by the feature or API resource they target.

    /tests
      /products
      /users
      /authentication
  • By API Version: If you work with multiple versions of an API, you can use folders to separate the tests.

    /tests
      /v1
      /v2

Tags for Flexible Grouping

Tags allow you to create flexible, cross-cutting groups of tests that span across different folders. This is perfect for categorizing tests by their purpose or priority.

Common Tagging Patterns:

  • By Test Type: #smoke, #regression, #e2e
  • By Priority: #p1 (high priority), #p2
  • By Feature: #login, #checkout (useful for running all tests related to a feature, regardless of their folder)

2. The Payoff: The Test Runner

The true power of good organization becomes clear when you create a Test Runner.

Inside a runner, the Selector Node allows you to dynamically build a test suite based on the folders and tags you’ve set up. For example, you can configure a selector to:

  • Run every test in the /products folder and all its sub-folders.
  • Run every test tagged with #smoke and #p1.

This means you never have to manually update your test suites. As long as new tests are placed in the correct folder or given the right tag, they are automatically included in the next run.

3. The Importance of Naming

Clear naming is one of the most important aspects of a maintainable test project.

Name Your Test Cases Clearly

A test case name should describe its exact intention.

  • Good: Get User Profile - Fails for Inactive User
  • Bad: User Test 2

A good name makes it easy to understand what a test does just by reading the test results, without having to open the test case itself.

Name Your Steps Explicitly

Within a test flow, every node should have a descriptive name. This turns your test flow from a generic diagram into a readable, self-documenting story of what the test is doing.

  • Good:

    • API: Get User Token
    • CONTEXT: Save Auth Token
    • API: Get User Profile
    • IF: User Status is Active
  • Bad:

    • API
    • CONTEXT
    • API
    • IF