»Command: test

The sentinel test command runs policies against the Sentinel test framework.

To learn more about testing, see the testing policies page.


Usage: sentinel test [options] [PATH] ...

This command runs the defined test cases against a set of policies.

The test cases are expected to live at the path test/<policy>/*.[hcl|json] relative to the policy being tested. <policy> should be the name of the policy excluding the file extension. The files should be in the configuration file structure. The test key is used for assertions.

The PATH arguments specified may be a list of zero or more files or directories. When no arguments are given, it defaults to the current directory. When a directory is given, all policies ending with the extension .sentinel are tested.

The command-line flags are all optional. The list of available flags are:

  • -color - Enable or disable colorized output. Enabled by default if running interactively.

  • -json - Suppress normal output and output test results as a JSON document. See the testing JSON output section for more details.

  • -run=regexp - Run only tests matching the regular expression pattern. A / splits policy name and test case name.

  • -verbose - Show tracing and log output for tests that succeed in addition to tests that fail. By default, traces and logs are only shown for tests that fail.