← 返回命令列表

Linux command

cotton 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run a single test specification

cotton [spec.md]

Run all specs in a directory

cotton [tests/]

Run with a custom base URL

cotton -u [https://api.example.com] [tests/]

Run in detail mode

cotton -d [spec.md]

Inject a predefined variable

cotton -p [token=abc123] [spec.md]

Stop on the first failure

cotton -s [tests/]

Watch for changes

cotton -w [tests/]

说明

cotton is a command-line test runner that executes RESTful API tests written in Markdown format. Test specifications are Markdown files containing HTTP request descriptions and expected response assertions, making tests human-readable as living documentation. Cotton reads each Markdown spec, extracts HTTP request definitions and expectations, executes the requests against the target API, and reports pass/fail results. The `_test-cases_` argument can be a single Markdown file, a directory of Markdown files, or a glob pattern. Variables can be injected with -p and referenced inside specs using `{{ variable_name }}` syntax. Cotton supports setup and teardown operations within spec files, and distinguishes between test cases (with assertions) and executables (without).

参数

-u _url_
Base URL for all requests (default: http://localhost:8080).
-i
Insecure mode: disable TLS certificate verification.
-d
Detail mode: print comprehensive output for each test.
-w
Watch mode: rerun tests automatically when files change.
-s
Panic mode: halt execution on the first failure.
-p _name=value_
Inject a predefined variable into test specs (repeatable).
-h
Display help information.
-v
Display version information.

FAQ

What is the cotton command used for?

cotton is a command-line test runner that executes RESTful API tests written in Markdown format. Test specifications are Markdown files containing HTTP request descriptions and expected response assertions, making tests human-readable as living documentation. Cotton reads each Markdown spec, extracts HTTP request definitions and expectations, executes the requests against the target API, and reports pass/fail results. The `_test-cases_` argument can be a single Markdown file, a directory of Markdown files, or a glob pattern. Variables can be injected with -p and referenced inside specs using `{{ variable_name }}` syntax. Cotton supports setup and teardown operations within spec files, and distinguishes between test cases (with assertions) and executables (without).

How do I run a basic cotton example?

Run `cotton [spec.md]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -u _url_ do in cotton?

Base URL for all requests (default: http://localhost:8080).