Skip to content

Test Commands

Test commands execute and manage tests across the repository.

They provide parallel test execution, suite-based organization, and comprehensive failure diagnostics for quality assurance.

Key Characteristics:

  • Parallel test execution by default
  • Suite-based test organization
  • Module-aware test discovery
  • Detailed failure diagnostics
  • Integration with BDD/Gherkin specs

When to use: When running tests during development, in CI/CD pipelines, or debugging test failures.

Commands in this Category

Command Purpose
test Test one or more modules
test debug Parse test results and list failures
test export-manual Export manual test scenarios
test import-manual Import manual test results
test list-suites List all available test suites
test merge-results Merge manual results into test manifest
test suite Run tests for a specific test suite

Test Organization

Module-Based Testing

Tests are organized by module, with each module containing its own test files:

go/src/auth/
├── auth.go
├── auth_test.go
└── specs/
    └── authentication.feature

Suite-Based Testing

Tests can also be grouped into logical suites that span multiple modules:

# Test suite configuration
suites:
  - name: integration
    modules: [src-api, src-auth, src-database]
  - name: unit
    modules: [eac-core, eac-commands]

Common Workflows

Running Tests During Development

# Test all modules
eac test

# Test specific module
eac test src-auth

# Test multiple modules
eac test src-auth src-api

Running Test Suites

# List available suites
eac test list-suites

# Run specific suite
eac test suite integration

# Run suite with verbose output
eac test suite integration --verbose

Debugging Test Failures

# Run tests and capture failures
eac test src-auth

# Parse failures for debugging
eac test debug

# Show detailed failure information
eac show test-summary src-auth

CI/CD Integration

# Run tests in CI (unit + integration for PR, add acceptance for main)
eac test --suite unit+integration

# Run specific suite for stage
eac test --suite acceptance

# Check test results
eac show test-timings

Test Execution Modes

Sequential Execution

Run tests one at a time:

eac test src-auth --sequential

Use when:

  • Debugging test failures
  • Tests have resource contention
  • Need predictable execution order

Parallel Execution (Default)

Run tests concurrently:

eac test src-auth src-api
# Runs in parallel by default

Use when:

  • Running in CI/CD
  • Tests are independent
  • Need fast feedback

Test Types

Unit Tests

Go standard testing framework:

func TestAuthentication(t *testing.T) {
    // Test implementation
}

Run with: eac test <module>

BDD/Gherkin Tests

Godog framework for behavior-driven development:

Feature: User Authentication
  Scenario: Valid login
    Given a registered user
    When they provide valid credentials
    Then authentication succeeds

Run with: eac test <module> (automatically detected)

Integration Tests

Tests spanning multiple modules:

# Run integration suite
eac test suite integration

Test Discovery

Automatic Discovery

Tests are automatically discovered based on:

  • *_test.go files for Go tests
  • *.feature files for Gherkin specs
  • Module contracts defining test locations

Manual Suite Configuration

Define custom test suites:

# .eac/contracts/test-suites.yml
suites:
  - name: smoke
    description: Quick smoke tests
    modules: [src-api]
    tags: ["@smoke"]

  - name: regression
    description: Full regression suite
    modules: [src-auth, src-api, src-database]
    tags: ["@regression"]

Test Output

Default Output

eac test src-auth

# Output:

Testing module: src-auth
Running 15 tests...
 TestValidateUser (0.12s)
 TestAuthentication (0.34s)
 TestAuthorization (0.21s)

15 tests, 14 passed, 1 failed
Total time: 2.3s

Verbose Output

eac test src-auth --verbose

# Shows:
# - Individual test output
# - Step-by-step execution for BDD tests
# - Stack traces for failures
# - Resource usage

JSON Output

eac get tests | jq '.'

# Structured test metadata

{
  "tests": [
    {
      "module": "src-auth",
      "file": "auth_test.go",
      "tests": ["TestValidateUser", "TestAuthentication"]
    }
  ]
}

Test Performance

Analyzing Test Times

# Show test timing data
eac show test-timings

# Get slowest tests
eac get test-timings | jq '[.tests[]] | sort_by(.duration) | reverse | .[0:10]'

Optimizing Test Execution

# Run only fast tests
eac test suite unit

# Skip slow integration tests
eac test --exclude-tags @slow

# All suites (parallel is default)
eac test --suite unit+integration+acceptance

Common Patterns

Pre-commit Testing

# Test affected modules
CHANGED=$(eac get changed-modules | jq -r '.changed_modules[]')
eac test $CHANGED

CI Pipeline Testing

# Full test suite with coverage
eac test --suite unit+integration+acceptance --coverage

# Acceptance tests for thorough testing
eac test --suite acceptance

# Integration tests with coverage
eac test --suite integration --coverage

Test-Driven Development

# Watch and re-run tests
while true; do
  eac test src-auth
  sleep 2
done

Test Tagging

Gherkin Tags

@smoke @api
Feature: API Authentication

  @positive
  Scenario: Valid credentials
    Given a registered user
    When they authenticate
    Then access is granted

  @negative @slow
  Scenario: Invalid credentials
    Given invalid credentials
    When they authenticate
    Then access is denied

Running Tagged Tests

# Run smoke tests only
eac test --tags @smoke

# Exclude slow tests
eac test --exclude-tags @slow

# Multiple tags (AND)
eac test --tags @api,@positive

Failure Handling

Immediate Failure

Stop on first failure:

eac test --fail-fast

Collect All Failures

Continue running all tests:

eac test --continue-on-error

Debug Failures

# Parse test output for failures
eac test debug

# Show only failures
eac test src-auth | grep "✗"

# Get detailed failure report
eac show test-summary src-auth

Test Coverage

Generate Coverage

# Run with coverage
eac test src-auth --coverage

# View coverage report
go tool cover -html=coverage.out

Coverage Thresholds

# Enforce minimum coverage
eac test --coverage --coverage-threshold 80

Integration with Other Commands

Build and Test

# Build before testing
eac build src-auth && eac test src-auth

Validate Before Commit

# Validate changes
eac validate

# Run tests
eac test

# Commit if passing
eac work commit --all

Best Practices

Test Frequently

# Test during development
# After each significant change
eac test

Use Appropriate Granularity

# Development: Test single module
eac test src-auth

# Pre-commit: Test changed modules
eac test $(eac get changed-modules | jq -r '.changed_modules[]')

# CI: Test all modules with all suites
eac test --suite unit+integration+acceptance

Organize with Suites

# Fast feedback with unit tests
eac test --suite unit

# Comprehensive validation with all suites
eac test --suite unit+integration+acceptance

Monitor Performance

# Track test times
eac show test-timings

# Identify slow tests
eac get test-timings | jq '[.tests[]] | sort_by(.duration) | reverse'

Common Issues

Tests Fail Locally but Pass in CI

Problem: Environment differences

Solution: Use consistent test environment

# Or use workspace isolation
eac work create test/investigation
cd ../work/test-investigation
eac test

Flaky Tests

Problem: Tests pass/fail intermittently

Solution: Run multiple times and analyze

# Run test multiple times
for i in {1..10}; do
  eac test src-auth
done

# Identify flaky tests
eac test debug

Slow Test Suite

Problem: Tests take too long

Solution: Analyze and optimize

# Find slowest tests
eac show test-timings

# Run only fast tests during development
eac test --suite unit

# Run all suites (parallel is default)
eac test --suite unit+integration+acceptance

Test Discovery Issues

Problem: Tests not being found

Solution: Verify module contracts

# Check module configuration
eac show modules

# Validate contracts
eac validate

See Also


Tutorials | How-to Guides | Explanation | Reference

You are here: Reference — information-oriented technical descriptions of the system.