Skip to main content

What is Context?

Context in Testpilot is additional information that helps the AI better understand:
  • How your application works
  • Special requirements or conditions for tests
  • Expected behaviors or edge cases
  • Login credentials or test data
Context is passed to the AI model along with your test steps, helping it make better decisions during test execution.

Adding Context to Your Tests

You can add context at two levels in your pilot files:

1. Global Context (Test Suite Level)

Global context applies to all test cases in a file. Add it at the root level of your test file:
name: "E-commerce Test Suite"
login_url: "https://example.com/login"
context:
  - text: "This is an e-commerce site that sells electronics"
  - text: "The navigation menu is at the top of every page"
  - text: "Product search requires at least 3 characters"
  - text: "Prices are displayed in USD"
cases:
  # Test cases will inherit all the context above
  - id: "test-001"
    # ...

2. Test-Specific Context (Test Case Level)

Test-specific context applies only to a single test case:
cases:
  - id: "checkout-test-001"
    name: "Complete Checkout"
    description: "Test the full checkout process"
    url: "https://example.com/cart"
    context:
      - text: "The checkout process has 3 steps: shipping, payment, and confirmation"
      - text: "Credit card validation happens in real-time as the user types"
      - text: "For test purposes, use credit card number: 4111 1111 1111 1111"
    steps:
      # These steps have access to both global and test-specific context
      - "Click on the checkout button"
      - "Fill in shipping information"
      # ...

Best Practices for Adding Context

Be Specific and Relevant

Add context that directly helps with test execution:
context:
  - text: "The login button changes to 'Logging in...' while processing"
  - text: "Error messages appear below each form field"
  - text: "The user menu is only visible after successful login"

Explain UI Components

Describe important UI elements and their behavior:
context:
  - text: "The navigation uses a hamburger menu on mobile screens"
  - text: "The search bar expands when clicked"
  - text: "The product filter sidebar can be collapsed by clicking the X button"

Provide Business Rules

Include relevant business logic or validation rules:
context:
  - text: "Promotional codes are case-sensitive and must be entered without spaces"

Specify Test Environment Details

Include information about your test environment:
context:
  - text: "This is a staging environment and emails are not actually sent"
  - text: "The payment gateway is in test mode"
  - text: "API responses may be delayed by 1-2 seconds in this environment"

When to Use Additional Context

Add extra context when:
  1. Your application has unique or complex behaviors that might not be immediately obvious
  2. Test steps require specific knowledge about the application state or business rules
  3. Handling error conditions or edge cases that require special treatment
I