Create tests from the CLI

Learn to create, validate, and run tests from the CLI using JSON definitions for API, web, smartphone, and SIM channels.

ktm creates tests from a JSON definition, so test authoring is scriptable and fits naturally into CI and AI coding agents like Claude Code or Codex. The flow is the same for every channel: scaffold a template for the action types you need, fill in the placeholders, validate, then create.

The flow

1
Browse action types

ktm tests action-types lists every type (44 across API, web, smartphone, and SIM) with its channel.

2
Scaffold a template

ktm tests template <TYPE...> > test.json writes one action per type, with placeholder <...> values.

3
Fill in the placeholders

Set the request/URL, assertions, and each action's owner (a device identifier).

4
Validate

ktm tests validate --from-file test.json checks the definition without creating it.

5
Create

ktm tests create --from-file test.json --product my-operator~my-product.

An action's owner takes a device identifier from ktm resources list: web agents by hostname (--type web-agent), SIMs by MSISDN (--type sim), smartphones by UUID (--type smartphone). Ownerless actions (JAVASCRIPT, SLEEP) use "".

By channel

Pick the action type that matches the scenario. Browse the full set with ktm tests action-types, and author the step details from the Actions Library.

ktm tests template ETH_HTTP_API > api_test.json
# fill in url, method, assertions...
ktm tests create --from-file api_test.json --product my-operator~my-product

ETH_HTTP_API sends an HTTP request and asserts on status, headers, or JSON body. See API scenarios.

Multi-step tests

Pass several action types to scaffold a sequence that runs top to bottom:

# Authenticated API flow: call, process the response, call again
ktm tests template ETH_HTTP_API JAVASCRIPT ETH_HTTP_API > auth_flow.json

Use a JAVASCRIPT action between API calls to build a request body or transform data with test.variables.get() / set().

Pin an environment

Tests resolve each variable's value per variant. Pin a group's variant at create time (others use their default):

ktm tests create --from-file test.json --product acme~web --variant API:Staging

What's next?

Build & run campaigns

Turn your tests into a runnable campaign and read results.

Actions Library

Author the step details for each channel.

Last updated on