A declarative test framework for Terraform using Gherkin BDD syntax to write unit and fitness function tests for HCL.
Clarity is a declarative test framework for Terraform that allows developers to write unit and fitness function tests for their infrastructure code using Gherkin BDD syntax. It solves the problem of validating Terraform HCL configurations by providing a simple, binary-based tool with built-in Terraform-specific matchers, enabling tests to be written as feature files without additional Go code.
Terraform developers and DevOps engineers who need to validate infrastructure as code for correctness, policy compliance, and consistency before deployment.
Developers choose Clarity because it simplifies Terraform testing with a declarative, BDD-driven approach, eliminating the need to write custom Go test code while providing specialized matchers for Terraform resources and attributes directly from their HCL files.
A declaritive test framework for Terraform
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows writing tests in Gherkin feature files without any Go code, as emphasized in the README: 'no need to write steps or go code. just write a declarative feature file.' This lowers the barrier to entry for infrastructure testing.
Provides built-in step definitions tailored for Terraform resources and attributes, such as validating 'aws_lb' resources or checking attribute equality, which simplifies common validation tasks directly from HCL.
Uses Gherkin-inspired syntax (Given/When/Then) for human-readable tests, making it easier for teams to collaborate and understand infrastructure requirements, as shown in the example feature file with scenarios.
Offers configurable concurrency levels via CLI options (e.g., -c flag) for faster test runs, improving feedback loops in development or CI/CD pipelines.
Primarily supports Terraform <=0.11 and HCL2, as noted in the README, which may not fully accommodate newer Terraform versions or advanced HCL2 features, risking compatibility issues.
Must be run from the directory where Terraform files reside, as stated: 'must be run from the directory where your terraform files live.' This restricts testing for remote or distributed configurations.
Relies on a fixed set of predefined matchers; the README provides no mechanism for custom step definitions, limiting adaptability to unique testing scenarios beyond basic assertions.