Modules Continuous Integration Testing (Beta)

env0's module testing feature allows you to stay on top of your modules’ health at any point, running tests with any change done to your modules. All information will be visible within env0 and your VCS, providing a quick and clear view of your module's status and allowing you to identify and remediate issues quickly for your modules’ consumers.

📣

CI Testing is a beta feature, currently available to all customers.

Writing tests with OpenTofu tftest files

Module testing in env0 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 env0.

Set Testing Credentials and Self Hosted Agent

As your tests are executed by env0, 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.

When testing is enabled, 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 Inheritance

Organization 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 support

Module tests will always run on the latest version of the module.

Tracking test results your VCS and in env0

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.

In env0, within each module, the Tests tab will show all historical testing runs executed on this module.

An overview recap of success, skipped, failed, and errored tests is given for each run. You can also see the type of run and which commit triggered the test execution.

Click any record in order to drill down into the logs of the specific run.

Within the Test Logs you'll be able to see the full details of the test execution. Each test file will have its own step with a success or failed status, and clicking the step will show the full breakdown of all test runs included in this file.