Terratest is an Apache-2.0 Go library maintained by Gruntwork that provides helper functions and patterns for writing automated tests against infrastructure code, and it is aimed at engineers who validate Terraform modules, Packer templates, Docker images, Kubernetes resources and AWS, Azure or GCP infrastructure inside a Go test suite.
What it is
Terratest lives in the Go ecosystem and is distributed as the module github.com/gruntwork-io/terratest. It supplies reusable helper functions for the tasks that show up repeatedly when infrastructure is tested rather than assumed: applying Terraform code, building Packer templates, running Docker images, executing commands on servers over SSH, calling the AWS, Azure, GCP and Kubernetes APIs, exercising Helm charts, making HTTP requests and running shell commands. The repository carries the topics aws, devops, docker, golang, packer, terraform, testing and testing-library, which reflects the breadth of those integrations.
The concrete problem it solves is harness duplication. Without a shared library, each team writes its own provider-specific code for provisioning resources, waiting for them to become ready, asserting on the result and cleaning up afterwards, and that code is rewritten for every repository. Terratest packages those operations behind a single Go dependency, so an infrastructure test is written once in Go and executed with the standard go test tooling rather than through bespoke scripts per project.
Key capabilities
- Testing Terraform code, Packer templates and Docker images through dedicated helper packages rather than raw command invocation.
- Executing commands on remote servers over SSH.
- Working with the AWS, Azure, GCP and Kubernetes APIs directly from test code.
- Testing Helm charts as part of the same suite.
- Making HTTP requests and running shell commands from tests.
- Semantic versioning from v1.0.0 onward, with breaking public API changes reserved for major releases and renamed or replaced v1 symbols kept behind
// Deprecated: annotations pointing at their replacement.
- Version pinning support, documented separately from the default
@latest install, so a consumer can lock to a specific release.
Who uses it and how
- Teams that treat Terraform as production code and want module behaviour verified by a real apply-and-assert cycle inside a Go test.
- Platform and DevOps groups standardising test structure across repositories, using one library for Terraform, Packer, Docker, Helm and the major cloud APIs instead of per-repo harness code.
- Kubernetes and Helm consumers who need chart rendering and cluster interaction covered by the same test runner.
- Organisations that must stay on the v1 line: with v2 in development, v1 receives security fixes only, delivered on the
v1 branch until twelve months after v2.0.0 reaches general availability, and v2 ships under new /v2 module paths so pinned v1 consumers are unaffected.
Getting started
Install with go get github.com/gruntwork-io/terratest@latest, which requires Go 1.26 or later. To lock to a specific release instead of @latest, the project documents a pinning procedure and a quick-start guide on its documentation site.
How it compares
No list of paid products this project replaces is provided in the facts. No directly comparable testing tool is named either, so on the available evidence Terratest stands alone in this registry: the tools named in its documentation are the subjects it tests, namely Terraform, Packer, Docker, Kubernetes and Helm, not alternatives to it.
When to use it — and when not to
Adopters must supply a working Go 1.26 or later toolchain, and the cloud and Kubernetes helper packages presuppose credentials for the environments under test, so the library itself is not the operational burden. Teams not already on Go should weigh that dependency, since the suite is a Go test suite. The clearest current limitation is lifecycle: v1 has entered maintenance and receives security fixes only, while v2 is still in development, so new adopters should decide deliberately between the stable but frozen v1 line and the moving v2 module paths.
project readme (upstream, from github) — read inline
Terratest

Terratest is a Go library that makes it easier to write automated tests for your infrastructure code. It provides a
variety of helper functions and patterns for common infrastructure testing tasks, including:
- Testing Terraform code
- Testing Packer templates
- Testing Docker images
- Executing commands on servers over SSH
- Working with AWS APIs
- Working with Azure APIs
- Working with GCP APIs
- Working with Kubernetes APIs
- Testing Helm Charts
- Making HTTP requests
- Running shell commands
- And much more
Install
go get github.com/gruntwork-io/terratest@latest
Requires Go 1.26 or later. To lock to a specific release instead of @latest, see Pinning a Terratest version.
Stability and versioning
Starting with v1.0.0, Terratest follows semantic versioning. Breaking changes to the public API
only happen in major releases (e.g. v2.0.0).
Symbols renamed or replaced in v1 are kept with // Deprecated: annotations pointing at the new name; removals happen
in v2. Migrating from v0.x: see the v1 migration guide. Migrating from v1 to v2: see the v2 migration guide.
v1 maintenance. With v2 in development, the v1 line has entered maintenance: it receives security fixes only,
delivered on the v1 branch, until 12 months after v2.0.0 reaches general availability. v2 ships under new /v2
module paths, so pinned v1 consumers are unaffected. Upgrade on your own schedule.
More info
License
This code is released under the Apache 2.0 License. Please see LICENSE and NOTICE for more details.
Copyright © 2025 Gruntwork, Inc.