Tests

As from 2.1, the test command is supported. The plugin does not support text output of the tests but generates everything into JSON format and then converts that to JUnit XML and produces a basic HTML report.

Layout

The task reacts to files in the source set’s root which match the patterns '*.tftest.hcl', '\*.tftest.json', '*.tofutest.hcl', '\*.tofutest.json'. It also looks for files in a test subdirectory, which by default, is called test.

Configuration

build.gradle
opentofu {
  sourceSets {
    main {
      executionOptions {
        testing {
          verbose = true (1)
        }
      }
      testSubdir = 'testing' (2)
    }
  }
}
1 Whether to include the plan and state for each test run. Equivalent of passing -verbose to tofu on the command-line. Default is false.
2 Override the default test directory. Default, by convention, is `test.

Test filters

Pass --filter on the Gradle command-line one or more times to specify tests that should be executed.

$ ./gradlew tofuTest --filter test/mytest.tofutest.hcl