This directory contains organized integration tests for the OADP CLI.
-
help_test.go- 🏆 Help command tests (baseline functionality)- Tests all
--helpand-hcommands across all paths - Verifies expected help text appears
- Core functionality that must always work
- Tests all
-
build_test.go- Binary building and execution tests- Tests that binary can be built successfully
- Smoke tests for basic command execution
- Version and basic functionality tests
common.go- Shared test utilities and helper functionsmain_test.go- Test setup and teardowngo.mod- Module configuration
# Standard Go command - runs all tests in project
go test ./...
# Run just the CLI tests
go test -v -timeout 60s ./tests
# From tests directory
cd tests && go test -v -timeout 60s# From project root
go test -v ./tests -run TestCLIHelp # Help command tests
go test -v ./tests -run TestCLIBinary # Build and smoke tests
# From tests directory
go test -v -run TestCLIHelp # Help command tests
go test -v -run TestCLIBinary # Build and smoke tests# Standard Go pattern - finds all tests
go test ./...
# Just CLI tests
go test ./tests
# With output
go test -v ./testsThese are the core functionality tests - verify all help commands work:
TestCLIHelpCommands- All help commands work across all pathsTestCLIHelpFlags- Both--helpand-hwork consistently
Tests that verify the binary itself works:
TestCLIBinaryBuild- Binary builds and executesTestCLIBinaryVersion- Version command worksTestCLIBinarySmoke- Basic commands don't crash
- Build timeout: 30 seconds
- Test timeout: 10 seconds per test
- Binary name:
oadp-test(temporary) - Tests local code: Whatever is currently on disk (including uncommitted changes)
Add new test cases to the appropriate file:
// In help_test.go for new help commands
{
name: "new command help",
args: []string{"new", "command", "--help"},
expectContains: []string{
"Description of new command",
},
},- Create a new
*_test.gofile - Import the
testspackage - Use helper functions from
common.go - Follow existing patterns
Example:
package tests
import "testing"
func TestCLINewFeature(t *testing.T) {
binaryPath := buildCLIBinary(t)
defer cleanup(t, binaryPath)
// Your test logic here
}- Check that all dependencies in
../go.modare available - Verify you're running from the correct directory
- Check that parent directory has valid Go module
- Check expected strings match actual CLI output
- Use
-vflag to see detailed test output - Look at the full command output in logs
# Run with verbose output
go test -v ./tests
# Run with race detection
go test -race ./tests
# Run specific test function
go test -v ./tests -run TestCLIHelpCommands
# Run tests with coverage
go test -cover ./tests