Writing tests with OpenTofu tftest files
Module testing in env zero uses Opentofu test command. Start by writing your tests as tftest files. All of your module test files have to be saved within the VCS folder of your module in order to be executed by env zero.Set Testing Credentials and Self Hosted Agent
As your tests are executed by env zero, you can select which credentials are used for execution. Go to Registry Settings and select credentials to be used in the tests execution.If youโre using Self Hosted Agents, you can also set up which Self Hosted Agent will be used to execute the tests.
The credentials and agent will apply to tests executed on all modules in the registry.
Enable & Run tests
Configure module testing
When creating or editing a module, go to the Testing step and check Enable Testing.
test
will be executed on each commit to the repository default branch. You can enable โRun tests on every PRโ to make sure tests are also executed on each commit to a pull request targeting the default branch.
Select OpenTofu version or default to the latest version, then set up any variables required for your test execution.
Organization Variable InheritanceOrganization Variables will be inherited by your module registry and applied to each test execution. You can override the organization variables in the Module level.
Manually trigger tests
You can also manually trigger a module run by clicking โRun Testsโ on the module details page. A run will be immediately queued and you can see its details in the Tests tab.Version supportModule tests will always run on the latest version of the module.
Tracking test results your VCS and in env zero
When tests run is triggered by a commit, youโll be able to see status checks in your VCS indicating the test results triggered by the commit.

