A command-line educational tool for teaching beginners how to use Go's testing framework through interactive tutorials and examples.
- Learn Mode: Read about Go testing concepts step-by-step
- Generate Mode: Create test templates for your Go code
- Run Mode: Execute and analyze Go tests with helpful explanations
- Interactive Tutorial: Walk through all Go testing concepts interactively
# Build the executable
go build -o gotest-learn
# Make it available in your path (optional)
cp gotest-learn /usr/local/bin/# List all available topics
./gotest-learn learn
# Read about a specific topic (e.g., topic 1: Introduction)
./gotest-learn learn 1
# Start interactive tutorial mode
./gotest-learn learn --interactive# List available templates
./gotest-learn generate
# Generate a basic test file
./gotest-learn generate --type basic --file mycode
# Generate a table-driven test file
./gotest-learn generate --type table --file mycode
# Generate a benchmark test file
./gotest-learn generate --type benchmark --file mycode# Run all tests in current directory
./gotest-learn run
# Run tests in a specific file
./gotest-learn run --file mycode_test.go
# Run tests in a specific directory
./gotest-learn run --dir ./mypackage
# Run tests in verbose mode
./gotest-learn run --verboseThe examples directory contains practical examples of Go testing techniques:
- Calculator Package: Demonstrates basic tests, table-driven tests, and benchmarks
- Basic tests in
calculator_test.go - Table-driven tests in
calculator_test.go - Benchmarks in
calculator_bench_test.go - Test helpers in
helpers_test.go
- Basic tests in
- Introduction to Go Testing
- Writing Basic Tests
- Test Assertions and Comparisons
- Table-Driven Tests
- Benchmarks
- Subtests and Test Organization
- TestMain and Setup/Teardown
- Test Helpers and Utilities
This project uses GitHub Actions for continuous integration and delivery:
- Builds and tests the code with Go 1.19
- Runs unit tests, benchmarks, and static code analysis
- Generates test coverage reports
- Checks for race conditions
- Builds cross-platform binaries for Linux, Windows, and macOS
- Prepares releases for tagged versions
You can see the current build status at the top of this README.
To create a new release:
- Update version in code if applicable
- Tag the commit:
git tag -a v1.0.0 -m "Release v1.0.0" - Push the tag:
git push origin v1.0.0
GitHub Actions will automatically build binaries and create a release with the following assets:
- Linux (64-bit) executable
- Windows (64-bit) executable
- macOS (64-bit) executable
Contributions are welcome! Feel free to submit pull requests or open issues for improvements or bug fixes.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-new-feature - Make your changes and add tests
- Run tests locally:
go test ./... - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/my-new-feature - Create a new Pull Request
MIT