Test Sections

Test Sections are organizational units within a test that group related test functions together. They help structure complex tests into logical parts, making them easier to understand and execute.

Overview

Test Sections provide structure within tests by organizing test functions into related groups. A test can have one or multiple sections, depending on the complexity of what needs to be verified.

Test Sections:

  • Group related test functions logically
  • Improve test readability and organization
  • Can have their own setup or context
  • Help break down complex verification procedures
  • Make it easier to navigate long tests

The Test Section Model

  • Name
    id
    Type
    string
    Description

    Unique identifier for the test section.

  • Name
    testId
    Type
    string
    Description

    ID of the test this section belongs to.

  • Name
    title
    Type
    string
    Description

    The title of the test section.

  • Name
    description
    Type
    string
    Description

    Description of what this section verifies.

  • Name
    order
    Type
    number
    Description

    The order of this section within the test.

  • Name
    functions
    Type
    array
    Description

    Array of test functions within this section.

  • Name
    createdAt
    Type
    timestamp
    Description

    Timestamp of when the section was created.

  • Name
    updatedAt
    Type
    timestamp
    Description

    Timestamp of when the section was last updated.

Creating Test Sections

Via the UI

  1. Navigate to a test
  2. Click "Add Section"
  3. Enter section details:
    • Title
    • Description (optional)
  4. Add test functions to the section
  5. Click "Save Section"

Via the API

// Create a test with sections
const testWithSections = await apiClient.tests.create(
  "sow_id",
  "task_item_id",
  {
    criterionId: "criterion_id",
    title: "Complete User Authentication Test",
    sections: [
      {
        title: "Login Validation",
        description: "Verify standard login functionality",
        functions: [
          // Test functions for login
        ]
      },
      {
        title: "Multi-Factor Authentication",
        description: "Verify MFA process",
        functions: [
          // Test functions for MFA
        ]
      },
      {
        title: "Session Management",
        description: "Verify session handling",
        functions: [
          // Test functions for sessions
        ]
      }
    ]
  }
);

When to Use Test Sections

Test sections are particularly useful when:

  • Complex Tests: The test involves multiple distinct areas of functionality
  • Different Contexts: Different parts of the test require different setups or contexts
  • Logical Grouping: Test functions naturally fall into distinct categories
  • Long Tests: The test has many functions that benefit from organization
  • Phased Testing: Different phases of testing (e.g., setup, execution, cleanup)

Examples of Test Section Organization

Example 1: API Endpoint Test

Test: Verify User Management API
├── Section 1: Authentication
│   ├── Function 1: Verify API key validation
│   └── Function 2: Verify token expiration
├── Section 2: Create Operations
│   ├── Function 1: Create user with valid data
│   └── Function 2: Validate required fields
└── Section 3: Error Handling
    ├── Function 1: Handle duplicate users
    └── Function 2: Handle invalid input

Example 2: UI Workflow Test

Test: Verify Shopping Cart Functionality
├── Section 1: Add Items
│   ├── Function 1: Add single item
│   └── Function 2: Add multiple quantities
├── Section 2: Modify Cart
│   ├── Function 1: Update quantities
│   └── Function 2: Remove items
└── Section 3: Checkout Process
    ├── Function 1: Apply discounts
    └── Function 2: Complete purchase

Best Practices

  • Meaningful Names: Give sections clear, descriptive titles
  • Logical Grouping: Group functions that test related functionality
  • Independent Sections: Each section should be understandable on its own
  • Appropriate Size: Avoid sections with too many or too few functions
  • Clear Purpose: Each section should have a clear testing objective
  • Sequential Flow: Order sections logically for test execution

Relationship to Tests and Functions

Understanding the hierarchy:

  1. Test: The overall verification procedure for a criterion
  2. Test Section: A logical grouping within the test
  3. Test Function: The specific instructions within a section

A test must have at least one section, and each section must have at least one function.

API Reference

Test sections are typically managed as part of the test structure. See the Tests API Reference for endpoints that include section management.

For complete API details on test structure management, refer to the API Reference.

Was this page helpful?