Skip to main content

Automated Suite Generation (rumour generate)

Writing dozens or hundreds of .toml request files and chaining them into suites by hand is tedious and error-prone. The rumour generate command is an automated scaffolding engine that builds deterministic, executable Rumour test suites and folder hierarchies in seconds.

Whether your team practices Design-First API development using OpenAPI/Swagger specifications or Code-First / Traffic-Driven testing by recording live API sessions, rumour generate eliminates manual boilerplate.


The Two Generation Workflows​

Rumour supports two complementary approaches to automated test suite generation:

Workflow 1: Design-First (OpenAPI / Swagger)​

Transforms OpenAPI 3.0/3.1 or Swagger 2.0 specifications (local YAML/JSON or remote URLs) into a complete, modular test workspace with environment configuration and master execution suites:

Workflow 2: Traffic-Driven (Recorded Session Snapshots)​

Converts captured live session traffic into deterministic test suites with automated assertions, payload extraction, and request deduplication:


1. Design-First: Generating from OpenAPI / Swagger​

If your service is defined with OpenAPI (v3.0, v3.1) or Swagger (v2.0) in YAML or JSON, Rumour parses the specification and automatically scaffolds a clean, modular project structure.

Command Syntax​

rumour generate --openapi <FILE_OR_URL> [OPTIONS]

You can point --openapi to either a local file path or a remote HTTP/HTTPS URL:

# Local YAML or JSON specification
rumour generate --openapi ./specs/petstore.yaml -o ./tests --base-url http://localhost:4000

# Remote specification URL
rumour generate --openapi https://petstore.swagger.io/v2/swagger.json -o ./petstore_tests

What Rumour Generates Automatically:​

  1. Workspace Root & Environment (workspace.env.toml):
    • Automatically populates base_url using the spec's servers or host/basePath entries (or the --base-url override).
    • Detects securitySchemes / securityDefinitions and creates placeholder variables:
      • HTTP Bearer $\rightarrow$ auth_token = ""
      • API Key $\rightarrow$ api_key = ""
      • OAuth2 $\rightarrow$ access_token = ""
  2. Tag-Based Subdirectories:
    • Operations are grouped into subdirectories matching OpenAPI tags (e.g. users/, pets/, orders/). Untagged endpoints default to general/.
  3. Deterministic TOML Request Files:
    • Files are named after operationId (e.g. getUserById.toml) or fallback to {method}_{path}.toml.
    • Path Parameters: Converts OpenAPI {param} syntax into Rumour {{param}} template syntax, pre-filling default parameter values inside the request's [variables] block.
    • Query Parameters & Headers: Automatically mapped into [params] and [headers] tables.
    • Request Bodies: Parses requestBody schemas and generates synthetic JSON payloads matching declared field types.
    • Status Assertions: Creates [assert] blocks asserting the expected response HTTP status code (e.g. status = 200 or status = 201).
  4. Modular Suite Files:
    • Generates a per-tag suite file (<tag>.suite.toml) and a top-level api_test_suite.suite.toml orchestrating the entire API collection.

Generated File Structure Example​

Given a PetStore OpenAPI specification:

tests/PetStore/
├── workspace.env.toml # Pre-filled base_url and security variables
├── api_test_suite.suite.toml # Top-level master suite orchestrating all tags
├── pets.suite.toml # Suite orchestrating all pet operations
├── pets/
│ ├── listPets.toml # GET /pets
│ ├── createPets.toml # POST /pets (with schema body)
│ └── showPetById.toml # GET /pets/{{pet_id}}
└── orders/
├── orders.suite.toml
└── placeOrder.toml # POST /orders

Generated Request File (pets/showPetById.toml):​

name = "Info for a specific pet"

[request]
method = "GET"
url = "{{base_url}}/pets/{{pet_id}}"

[variables]
pet_id = "1"

[assert]
status = 200

generate --openapi vs. import -f openapi​

A common question is how rumour generate --openapi differs from rumour import -f openapi. While both share the underlying OpenAPI parser, they serve fundamentally different roles in your workflow:

Capability / Featurerumour import -f openapirumour generate --openapi
Primary IntentMigration utility (1:1 conversion from Postman, Bruno, or OpenAPI).Scaffolding engine (building reproducible test suites and CI/CD pipelines).
Dry-Run Preview❌ No preview (writes files to disk immediately).✅ --dry-run prints an ASCII summary table of files scheduled for creation.
Base URL Override❌ None (locked to the URL specified inside the spec).✅ --base-url <URL> overrides the base URL written to workspace.env.toml.
Workspace Name Override❌ None (uses the spec's title as directory name).✅ -n, --name <NAME> overrides the generated collection folder name.
Live Traffic Support❌ OpenAPI, Postman, or Bruno spec files only.✅ Generates test suites from recorded session traffic (--from-sessions).
Filtering Capabilities❌ Ingests entire specification unconditionally.✅ Supports --filter-status and --filter-method for snapshots.
When to Use Which?
  • Use rumour import when you are doing a quick 1:1 migration of an existing Postman collection, Bruno directory, or OpenAPI spec into Rumour.
  • Use rumour generate when building new test architectures, testing boundary environments (pointing the spec at http://localhost:3000 via --base-url), auditing generated files with --dry-run, or synthesizing tests from live traffic.

2. Traffic-Driven: Generating from Recorded Sessions​

If you do not have an OpenAPI spec, you can record real API traffic and convert the recorded sessions directly into executable, deterministic test suites.

How Traffic is Captured​

Rumour captures session snapshots into .snapshot.json files via two commands:

  1. Live Test Recording: rumour run ./my_collection --record session.snapshot.json
  2. Reverse Proxy Interception: rumour mock intercept https://api.example.com

Converting Snapshots to Test Suites​

Run rumour generate --from-sessions pointing to the folder containing your snapshot recordings:

rumour generate --from-sessions .rumour/snapshots -o ./regression_suite

Filtering Snapshots​

When dealing with large session logs containing hundreds or thousands of calls, use status and method filters to extract only the operations you want:

rumour generate --from-sessions .rumour/snapshots \
--filter-status 200 \
--filter-status 201 \
--filter-method POST \
--filter-method GET \
-o ./smoke_tests

In this example, Rumour only generates tests for successful (200 or 201) GET and POST requests.

Key Features of Snapshot Conversion:​

  • Automatic Deduplication: Identical requests (matching method and URL) are deduplicated, keeping your generated suite concise.
  • Accurate Payloads & Headers: Uses exact recorded request bodies and headers.
  • Automated Assertions: Derives assertions from the recorded server response, including HTTP status codes, headers, and response structure.
  • Sensitive Variable Detection: Scans captured authorization headers and passwords, alerting you to extract them into environment files.
  • Deterministic Suite File: Generates api_test_suite.suite.toml with ordered = true preserving the exact execution chronology.

3. Dry-Run Preview Mode (--dry-run)​

Before writing files to your filesystem, you can use the --dry-run flag to preview what files and directory trees would be generated.

rumour generate --openapi ./api.yaml --dry-run

Terminal Output:

◆ Generating test suite from OpenAPI spec ./api.yaml (DRY RUN — no files written)...
[DRY RUN] Would write: pets/listPets.toml
[DRY RUN] Would write: pets/createPets.toml
[DRY RUN] Would write: pets/showPetById.toml

╔══════════════════════════════════════════════════════╗
║ OpenAPI Test Generation Summary (DRY RUN) ║
╠══════════════════════════════════════════════════════╣
║ pets/listPets.toml ║
║ pets/createPets.toml ║
║ pets/showPetById.toml ║
╚══════════════════════════════════════════════════════╝

DRY RUN: 3 test cases WOULD BE generated (DRY RUN) → ./

4. CLI Options Reference​

The table below summarizes all options available for rumour generate:

OptionFlagDescription
--openapi <FILE/URL>—OpenAPI/Swagger spec path or remote URL (http:// or https://).
--from-sessions <DIR>—Directory containing .snapshot.json session files to convert.
--output <DIR>-oTarget directory where the workspace will be generated (default: .).
--name <NAME>-nOverride the name of the generated workspace directory.
--dry-run—Preview generated files and structure without writing to disk.
--base-url <URL>—Override the base_url written into workspace.env.toml.
--filter-status <STATUS>—Only include snapshots matching this HTTP status (e.g. 200, 201). Can be repeated.
--filter-method <METHOD>—Only include snapshots matching this HTTP method (e.g. GET, POST). Can be repeated.
--env-file <FILE>-eSpecify an existing environment file to load alongside the generated workspace.
Combining Generate and Mock

A powerful workflow is pairing rumour generate with rumour mock:

  1. Generate test cases from your backend team's OpenAPI contract before backend code is written:
    rumour generate --openapi ./api-spec.yaml -o ./contract_tests
  2. Immediately compile and spin up the offline mock server:
    rumour mock compile ./contract_tests
    rumour mock start ./contract_tests -d -p 8080
  3. Run your tests against the mock server to verify your client or assertions:
    rumour run ./contract_tests -V base_url=http://127.0.0.1:8080
    rumour mock stop ./contract_tests