Command-line Interface

Command-line Interface#

Usage#

$ dredd '<api-description-document>' '<api-location>' [OPTIONS]

Example:

$ dredd ./api-description.yaml http://127.0.0.1:3000

Arguments#

api-description-document#

URL or path to the API description document (OpenAPI 3.0, OpenAPI 3.1). Sample values: ./openapi30.yml, ./openapi31.yml, ./openapi30.json, http://example.com/openapi31.yml

api-location#

URL, the root address of your API. Sample values: http://127.0.0.1:3000, http://api.example.com

Configuration File#

If you use Dredd repeatedly within a single project, the preferred way to run it is to first persist your configuration in a dredd.yml file. With the file in place you can then run Dredd every time simply just by:

$ dredd

Dredd offers interactive wizard to setup your dredd.yml file:

$ dredd init

See below how sample configuration file could look like. The structure is the same as of the Dredd Class configuration object.

reporter: html
dry-run: null
hookfiles: "dreddhooks.js"
server: rails server
server-wait: 3
init: false
names: false
only: []
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
loglevel: warning
path: ["api-description.yaml"]
endpoint: "http://127.0.0.1:3000"

CLI Options Reference#

Remember you can always list all available arguments by dredd --help.

--color#

Use –color/–no-color to enable/disable colored output Default value: true

--config#

Path to dredd.yml config file. Default value: "./dredd.yml"

--custom, -j#

Pass custom key-value configuration data delimited by a colon. E.g. -j ‘a:b’ Default value: []

--details, -d#

Determines whether request/response details are included in passing tests. Default value: false

--dry-run, -y#

Do not run any real HTTP transaction, only parse API description document and compile transactions. Default value: null

--header, -h#

Extra header to include in every request. This option can be used multiple times to add multiple headers. Default value: []

--help#

Show usage information.

--hookfiles, -f#

Path to hook files. Can be used multiple times, supports glob patterns. Hook files are executed in alphabetical order. Default value: null

--init, -i#

Run interactive configuration. Creates dredd.yml configuration file. Default value: false

--inline-errors, -e#

Determines whether failures and errors are displayed as they occur (true) or aggregated and displayed at the end (false). Default value: false

--loglevel, -l#

Application logging level. Supported levels: ‘debug’, ‘warning’, ‘error’, ‘silent’. The value ‘debug’ also displays timestamps. Default value: "warning"

--method, -m#

Restrict tests to a particular HTTP method (GET, PUT, POST, DELETE, PATCH). This option can be used multiple times to allow multiple methods. Default value: []

--names, -n#

Only list names of requests (for use in a hookfile). No requests are made. Default value: false

--only, -x#

Run only specified transaction name. Can be used multiple times Default value: []

--output, -o#

Specifies output file when using additional file-based reporter. This option can be used multiple times if multiple file-based reporters are used. Default value: []

--path, -p#

Additional API description paths or URLs. Can be used multiple times with glob pattern for paths. Default value: []

--reporter, -r#

Output additional report format. This option can be used multiple times to add multiple reporters. Options: xunit, nyan, dot, markdown, html, json. Default value: []

--require#

When using nodejs hooks, require the given module before executing hooks Default value: null

--server, -g#

Run API backend server command and kill it after Dredd execution. E.g. rails server Default value: null

--server-wait#

Set delay time in seconds between running a server and test run. Default value: 3

--sorted, -s#

Sorts requests in a sensible way so that objects are not modified before they are created. Order: CONNECT, OPTIONS, POST, GET, HEAD, PUT, PATCH, LINK, UNLINK, DELETE, TRACE. Default value: false

--user, -u#

Basic Auth credentials in the form username:password. Default value: null

--version#

Show version number.