Understanding Output Relay

What is Output Relay?

Output Relay is a mechanism that allows one test case to pass data to another test case within the same test pipeline. Think of it as a "data handoff" between tests.

Simple Analogy: Imagine a relay race where runners pass a baton. In Output Relay:

  • The baton is a variable (like a token, ID, or URL)
  • The first runner (Output Case) generates and passes the data
  • The next runner (Input Case) receives and uses that data
💡

Output Relay maintains test independence while enabling data dependencies. Each test case remains atomic and self-contained, but can share outputs when orchestrated in a pipeline.

Why Do You Need Output Relay?

The Problem: Hardcoded Dependencies

Without Output Relay, you might write tests like this:

Python
# Test A: Login and get token
def test_login():
    token = api.login("user", "pass")
    # Token is lost after this test ends!

# Test B: Get user profile (BROKEN - no token!)
def test_get_profile():
    token = "???"  # Where does this come from?
    api.get_profile(token)

Common workarounds (all problematic):

  • Hardcode tokens → Breaks when tokens expire
  • Combine into one giant test → Hard to maintain, slow to debug
  • Use global variables → Tests become interdependent and fragile

The Solution: Output Relay

With Output Relay, Test A can pass the token to Test B:

Output Relay Simple Flow

Each test stays independent, but data flows through the pipeline.

Core Concepts

Output Case vs Input Case

ConceptDescriptionExample
Output CaseA test case that produces data for other testsLogin test that generates an access token
Input CaseA test case that consumes data from other testsAPI test that uses the token to make requests
ℹ️

A test case can be both an Output Case and an Input Case simultaneously. For example, Test B might receive a token from Test A, then pass a user ID to Test C.

Relay Variable

A Relay Variable is a named variable that:

  1. Is declared in the Output Case's environment variables (on Testany Platform)
  2. Is populated by the Output Case's code at runtime
  3. Is consumed by the Input Case as an environment variable

Data Flow in a Pipeline

Here's how data flows through a typical pipeline with Output Relay:

Output Relay Pipeline Flow

In this example:

  • Case A outputs ACCESS_TOKEN
  • Case B inputs ACCESS_TOKEN, outputs USER_ID
  • Case C inputs both ACCESS_TOKEN (from A) and USER_ID (from B)

End-to-End Setup Overview

Setting up Output Relay involves three steps across two systems:

Output Relay Setup Overview

Step 1: Write Code to Output Data

In your Output Case, use the TESTANY_OUTPUT_RELAY_SERVICE environment variable to POST data:

Python
# Python example
import os
import requests

relay_service = os.environ.get('TESTANY_OUTPUT_RELAY_SERVICE')
requests.post(relay_service, json={
    'ACCESS_TOKEN': 'eyJhbGciOiJIUzI1NiIs...'
})

Step 2: Mark Variable as Relay on Platform

On the Test Case detail page, add an environment variable and click the relay icon to mark it as a relay variable.

Step 3: Configure Pipeline YAML

In your pipeline definition, use relay to connect cases:

YAML
kind: rule/v1.3
spec:
  rules:
    - run: A1B2C3D4  # Login case
    - run: E5F6A7B8  # Profile case
      relay:
        - key: ACCESS_TOKEN
          refKey: A1B2C3D4/ACCESS_TOKEN  # Reference login case's output
📝

For all new pipelines, rule/v1.3 is the recommended version. rule/v1.2 can still run, but it does not provide case-level parallel execution.

Constraints and Limitations

Relay Only Works with Passed Cases

⚠️

You can only relay data from a test case that passed. If the Output Case fails, aborts, or times out, its relay data is not available.

In rule/v1.3, this also means the test script that consumes relay data cannot be in a relationship where it might start at the same time as the test script that provides relay data. The platform requires the test script that provides relay data to finish before the test script that consumes relay data starts.

This means you cannot configure:

YAML
# INVALID - relay with whenFailed
- run: E5F6A7B8  # Input case
  whenFailed: A1B2C3D4  # Output case failed, no reliable data
  relay:
    - key: TOKEN
      refKey: A1B2C3D4/TOKEN

No Circular Dependencies

The platform automatically detects and rejects circular relay configurations:

YAML
# INVALID - circular dependency
- run: A1B2C3D4  # Case A
  relay:
    - key: X
      refKey: E5F6A7B8/Y
- run: E5F6A7B8  # Case B
  relay:
    - key: Y
      refKey: A1B2C3D4/X  # Error: circular dependency

Performance Testing Not Supported

Output Relay is designed for functional testing only. It is not available for performance/load testing scenarios.

Next Steps

Now that you understand the concepts, proceed to the implementation guides:

If you want to...Read this
Write relay code in your test scriptsManaging Test Case with Relay Case
Configure relay in pipeline YAMLBuild your tests more robust & flexible with Output Relay
Learn pipeline YAML syntaxPipeline YAML Schema Reference

Quick Reference

TermDefinition
Output RelayFeature that passes data between test cases in a pipeline
Output CaseTest case that produces relay data
Input CaseTest case that consumes relay data
Relay VariableNamed variable passed from Output Case to Input Case
TESTANY_OUTPUT_RELAY_SERVICEEnvironment variable containing the relay service URL
relay.refKeyPipeline YAML field that references another case's output

Still confused? The key insight is that Output Relay separates data generation (in code) from data routing (in pipeline YAML). Your test code only needs to POST data to the relay service. The platform handles the routing based on your pipeline configuration.

Still have questions?

Our team is here to help. Get in touch and we'll get back to you as soon as possible.