Build Flags
coverctl supports common test flags for customizing test execution. These flags are available on the check, run, and watch commands. The flags below apply to Go projects; other languages use their native test runners with equivalent options passed via --test-arg.
Available Flags
Section titled “Available Flags”| Flag | Description | Example |
|---|---|---|
--tags | Build tags | --tags integration,e2e |
--race | Enable race detector | --race |
--short | Skip long-running tests | --short |
-v | Verbose test output | -v |
--run | Run tests matching pattern | --run TestFoo |
--timeout | Test timeout | --timeout 30m |
--test-arg | Additional go test argument | --test-arg=-count=1 |
Build Tags
Section titled “Build Tags”Run tests with specific build tags:
# Run integration testscoverctl check --tags integration
# Multiple tagscoverctl check --tags integration,e2e
# Unit tests only (exclude integration)coverctl check --tags !integrationExample: Integration Tests
Section titled “Example: Integration Tests”//go:build integration
package mypackage_test
func TestIntegration(t *testing.T) { // This test only runs with --tags integration}coverctl check --tags integration --timeout 30mRace Detection
Section titled “Race Detection”Enable the Go race detector:
coverctl check --raceShort Mode
Section titled “Short Mode”Skip long-running tests marked with t.Short():
coverctl check --shortExample: Skipping Slow Tests
Section titled “Example: Skipping Slow Tests”func TestSlow(t *testing.T) { if testing.Short() { t.Skip("skipping slow test") } // Long-running test code}Verbose Output
Section titled “Verbose Output”Show detailed test output:
coverctl check -vUseful for debugging test failures.
Run Pattern
Section titled “Run Pattern”Run only tests matching a regex pattern:
# Run specific testcoverctl check --run TestValidate
# Run tests matching patterncoverctl check --run "TestUser.*"
# Run subtestscoverctl check --run "TestValidate/empty_input"Timeout
Section titled “Timeout”Set test execution timeout:
# 30 minutescoverctl check --timeout 30m
# 1 hourcoverctl check --timeout 1h
# 90 secondscoverctl check --timeout 90sDefault Go timeout is 10 minutes. Increase for:
- Integration tests
- Tests with external dependencies
- Tests with race detection
Additional Test Arguments
Section titled “Additional Test Arguments”Pass extra arguments directly to go test:
# Disable test cachingcoverctl check --test-arg=-count=1
# Set parallelismcoverctl check --test-arg=-parallel=4
# Multiple argumentscoverctl check --test-arg=-count=1 --test-arg=-parallel=4
# Enable CPU profilingcoverctl check --test-arg=-cpuprofile=cpu.outCommon Workflows
Section titled “Common Workflows”Development: Fast Feedback
Section titled “Development: Fast Feedback”# Quick unit tests onlycoverctl watch --short -d coreCI: Comprehensive Testing
Section titled “CI: Comprehensive Testing”# Full test suite with race detectioncoverctl check --race --timeout 30m --ciIntegration Tests
Section titled “Integration Tests”# Run integration tests with extended timeoutcoverctl check --tags integration --timeout 1h -vDebugging Failures
Section titled “Debugging Failures”# Verbose output for specific testcoverctl check --run TestFailing -v --test-arg=-count=1Parallel Execution
Section titled “Parallel Execution”# Limit parallel test executioncoverctl check --test-arg=-parallel=2Combining Flags
Section titled “Combining Flags”Flags can be combined for complex scenarios:
# Integration tests with race detection, verbose, extended timeoutcoverctl check \ --tags integration \ --race \ -v \ --timeout 1h \ --test-arg=-parallel=4CI Examples
Section titled “CI Examples”GitHub Actions: Integration Tests
Section titled “GitHub Actions: Integration Tests”- name: Run integration tests run: | coverctl check \ --tags integration \ --timeout 30m \ --ciGitHub Actions: Race Detection
Section titled “GitHub Actions: Race Detection”- name: Run with race detector run: | coverctl check \ --race \ --timeout 20m \ --ci