table-driven-test
Table-Driven Test Guidelines
Table-driven tests define multiple test cases in a slice of structs, then iterate over them executing the same test logic. This makes it easy to add cases, improves readability, and reduces duplication.
When to use table-driven tests:
- You have 3+ similar test cases that vary by inputs/outputs
- Tests follow the same logic pattern with different data
- Most unit and integration tests benefit from this structure
When to skip:
- Only 1-2 simple test cases (overhead not worth it)
- Each test requires completely different logic
- Test setup/teardown varies significantly between cases
Not the same as: Datadriven tests (different library with testdata files)
Basic Structure
More from cockroachdb/cockroach
commit-helper
Help create git commits and PRs with properly formatted messages and release notes following CockroachDB conventions. Use when committing changes or creating pull requests.
501backport-pr-assistant
Help backport PRs to release branches using the backport CLI tool. Use when backporting changes that have merge conflicts requiring manual resolution.
75reduce-unoptimized-query-oracle
Reduce an unoptimized-query-oracle test failure log to the simplest possible reproduction case. Use when you have unoptimized-query-oracle*.log files from a failed roachtest and need to find the minimal SQL to reproduce the bug.
63engflow-artifacts
Use when downloading test logs, artifacts, or outputs.zip from EngFlow build invocations. Use when investigating CockroachDB CI test failures hosted on mesolite.cluster.engflow.com.
29integration-test
Guidelines for writing integration tests with CockroachDB test servers, including when to use them and how to use sqlutils.
18bump-cluster-ui
Bump cluster-ui package version after a release branch cut. Creates two PRs — one to drop the prerelease suffix on the release branch and one to increment the minor version on master.
3