tmt-try
Test changes locally before submitting them
TLDR
Quickly experiment with the default provision method (no tests in the CWD)
Run a test in the current working directory
Use a specific operating system
Select both custom image and provision method
Select tests with custom filter
Provision guest and wait for instructions
Directly log into the guest without asking
Display help
SYNOPSIS
tmt try [OPTIONS] [PLAN...]
PARAMETERS
[PLAN...]
One or more paths to FMF-defined test plans to execute. If omitted, tmt searches for plans in the current directory.
-h, --help
Displays a help message and exits, showing available options and their usage.
--id ID
Specifies a unique run ID of a previous tmt run to resume or re-run.
--last
Re-runs the most recently executed tmt run, useful for quick iterations.
--filter FILTER
Includes tests matching the provided FMF filter expression (e.g., 'tier:1', 'tags:smoke').
--exclude EXCLUDE
Excludes tests matching the provided FMF filter expression.
--scratch
Executes the run in a clean, isolated, temporary work directory that is deleted afterwards.
--remove
Ensures the work directory is removed upon completion, regardless of success or failure.
--keep
Ensures the work directory is retained upon completion, useful for post-run inspection and debugging.
--dry
Performs a dry run, showing planned actions and selected tests without actual execution.
--rerun
Re-executes only tests that previously failed within the specified (or last) run.
--reboot
Allows the system under test to reboot during test execution if a test requires it.
--resume
Resumes an interrupted or failed tmt run from its last recorded state.
--force
Forces execution, ignoring some warnings or previous failures, useful for overcoming minor issues.
--report
Generates a test report in various formats (e.g., HTML, JUnit XML) upon completion.
--environment KEY=VALUE
Sets one or more environment variables for the test execution environment.
--work-dir DIR
Specifies a custom directory where tmt will store run-specific working files and results.
--until STAGE
Executes the test plan only up to and including the specified lifecycle stage (e.g., 'execute', 'report').
--since STAGE
Executes the test plan starting from and including the specified lifecycle stage (e.g., 'prepare', 'execute').
--verbose, --debug
Increases the verbosity of output messages, providing more detailed information for troubleshooting.
DESCRIPTION
The tmt-try command (typically invoked as tmt try) is a core component of the Test Management Tool (tmt) suite. It enables developers and testers to easily run, debug, and iterate on test plans and individual tests, primarily in local or temporary environments.
Unlike full-scale CI/CD orchestrations, tmt try focuses on providing a quick and flexible way to execute selected parts of a test plan, specific tests, or stages of the test lifecycle. This makes it invaluable for:
- Local development: Quickly verifying changes before committing.
- Debugging: Re-running failed tests, inspecting work directories, or executing up to a specific stage.
- Ad-hoc testing: Running a subset of tests with custom parameters.
It leverages tmt's Flexible Metadata Format (FMF) to discover and execute tests, providing options to filter, exclude, resume, or force execution, granting fine-grained control over the testing process.
CAVEATS
The command requires the tmt package to be installed on the system. Proper FMF test plans and metadata must be defined for tmt try to discover and execute tests correctly. Running tests that require specific provisioning (e.g., remote virtual machines) may necessitate additional setup and dependencies (e.g., tmt-provision-container or tmt-provision-virtual plugins).
FMF (FLEXIBLE METADATA FORMAT)
tmt try relies heavily on FMF to define test plans, tests, stories, and other metadata. FMF is a hierarchical YAML-based format that allows for flexible organization and discovery of test artifacts.
EXECUTION STAGES
tmt try orchestrates tests through a series of well-defined stages: Discover (find tests), Provision (set up environment), Prepare (install dependencies), Execute (run tests), Report (generate results), and Finish (clean up). The --until and --since options allow targeting specific stages for focused execution or debugging.
HISTORY
tmt (Test Management Tool) was developed by Red Hat and Fedora infrastructure teams to standardize and simplify test execution across various environments, from local development to large-scale CI/CD pipelines. tmt try emerged as a crucial component to address the interactive and debugging needs of developers, providing a focused interface for quick test iterations and deep analysis of failures, a common requirement in agile development workflows.