Inline Configuration
Scrut support two kinds of inline configuration syntax:
- Per Test Document (document-wide) configuration, which can be defined at the start of the test document
- Per Test Case (test-case-wide) configuration, which can be defined with each individual test case
This configuration method is only supported for test documents using the Markdown format. There is no equivalent in the Cram format.
Example
---
# optional document-wide YAML configuration
total_timeout: 30s
---
# The test document
The initial block that is initialized with `---` and terminated with `---` contains
the configuration in YAML notation.
## A simple test
```scrut
$ echo Hello One
Hello One
```
The above test does not contain any per-test configuration
## A test with configuration
```scrut {timeout: 10s}
$ echo Hello Two
Hello Two
```
The above test contains per-test configuration
Some inline-configuration attribute can overwritten by parameters provided on the command-line (see below). The order of precedence is:
- Command-line parameter
- Per Test Case configuration
- Per Test Document configuration
- Default
Test Document Configuration
All configuration that can be applied per test document.
append
- Type: list of paths to documents
- Command Line Parameter:
--append-test-file-paths
- Default:
[]
The append
configuration allows you to specify a list of document paths that should be included as if they were part of the current test document. All tests within the appended paths are executed after the tests defined in the current document. This is particularly useful for including common or shared test tear-down procedures. The paths specified must be relative to the current $TESTDIR
.
Example:
append:
- "common-teardown.md"
- "additional-tests.md"
Per-document configuration, including defaults, from appended documents is ignored.
defaults
- Type: object
- Command Line Parameter: n/a
- Default:
{}
The defaults
configuration allows you to specify default values for per-test-case configurations within the test document. These defaults are applied to each test case unless overridden by specific configurations within the test case itself. This is useful for setting common configurations that apply to multiple test cases, reducing redundancy and ensuring consistency across tests.
Example:
defaults:
timeout: "5s"
environment:
FOO: "bar"
In the above example, each test case will have a default timeout of 5 seconds and an environment variable FOO
set to "bar", unless these are explicitly overridden in the test case configuration.
prepend
- Type: list of paths to documents
- Command Line Parameter:
--prepend-test-file-paths
- Default:
[]
The prepend
configuration allows you to specify a list of document paths that should be included as if they were part of the current test document. All tests within the prepended paths are executed before the tests defined in the current document. This is particularly useful for including common or shared test setup procedures. The paths specified must be relative to the current $TESTDIR
.
Example:
prepend:
- "common-setup.md"
- "initial-tests.md"
Per-document configuration, including defaults, from prepended documents is ignored.
shell
- Type: string
- Command Line Parameter:
--shell
- Default (Linux, MacOS):
/bin/bash
- Default (Windows):
bash
The shell
configuration specifies the path to the shell that should be used to execute the test cases. If a full path is not provided, the shell command must be available in the system's $PATH
. Currently, only bash
compatible shells are supported. This configuration is useful when you need to run tests in a specific shell environment that might have different features or behaviors compared to the default shell.
Example:
shell: /bin/my-bash
You can also overwrite the default shell using the SCRUT_DEFAULT_SHELL
environment variable.
total_timeout
- Type: duration string
- Command Line Parameter:
--timeout-seconds
- Default:
15m
The total_timeout
configuration specifies the maximum duration allowed for all tests within the document to complete execution. This includes tests from both appended and prepended documents. If the total execution time exceeds this limit, the test run is aborted. This setting is useful for ensuring that test suites do not run indefinitely and helps in managing overall test execution time.
Example:
total_timeout: "30m"
Test Case Configuration
All configuration that can be applied per test case in Markdown test documents.