gotest

A smart, automated Go testing tool that runs standard tests, race detection, coverage analysis, and WebAssembly tests with zero configuration.
Features
- Zero Configuration: No flags or setup required - just run
gotest
- Automatic WASM Detection: Detects and runs WebAssembly tests automatically
- Intelligent Test Selection: Runs stdlib tests, WASM tests, or both based on your project
- Race Detection: Automatically runs race detection on stdlib tests
- Coverage Analysis: Calculates and reports test coverage
- Minimal Output: Clean, single-line summary in quiet mode
- Badge Generation: Automatically updates README badges with test results
- Go Vet Integration: Runs
go vet before tests
Installation
go install github.com/cdvelop/gotest/cmd/gotest@latest
Usage
Simply run gotest in your project directory:
gotest
Verbose Mode
For detailed output including all test logs:
gotest -v
Output Examples
Project with stdlib tests only
✅ vet passed, ✅ tests stdlib passed, ✅ race detection passed, ✅ coverage: 81%
Project with WASM tests only
✅ vet passed, ✅ tests wasm passed, ✅ coverage: 92%
Project with both stdlib and WASM tests
✅ vet passed, ✅ tests stdlib passed, ✅ race detection passed, ✅ coverage: 100%, ✅ tests wasm passed
When tests fail
=== RUN TestToJS
=== RUN TestToJS/int16
jsvalue_test.go:83: ToJS validation failed for int16
=== RUN TestToJS/uint
jsvalue_test.go:83: ToJS validation failed for uint
exit with status 1
✅ vet passed, ❌ tests wasm failed
Note: When tests fail, gotest shows:
- Which tests failed (e.g.,
TestToJS/int16, TestToJS/uint)
- Error messages with file and line numbers
- Clear failure indicators (❌)
- Filters out passing test output for clarity
How It Works
- Detects test files: Scans for
*_test.go files in your project
- Identifies WASM tests: Automatically detects WASM-specific test files (e.g.,
*Wasm*_test.go)
- Runs go vet: Validates code quality before running tests
- Executes stdlib tests: Runs standard Go tests with
go test ./...
- Race detection: Runs
go test -race ./... on stdlib tests
- Coverage analysis: Calculates test coverage from stdlib or WASM tests
- WASM tests: Automatically runs WASM tests using
wasmbrowsertest if detected
- Badge updates: Updates README.md with test status badges
WASM Test Auto-Detection
gotest automatically detects and runs WASM tests when:
- Files matching
*Wasm*_test.go or *wasm*_test.go are found
- Standard tests return "matched no packages" (indicating WASM-only tests)
No manual flags or configuration needed!
Auto-Installation of wasmbrowsertest
If WASM tests are detected but wasmbrowsertest is not installed, gotest will automatically:
- Clone the latest version from
github.com/tinywasm/wasmbrowsertest
- Install it to your
$GOPATH/bin
- Run your WASM tests
Benefits
For Developers
- Save Time: One command instead of multiple
go test, go vet, go test -race commands
- Consistency: Same testing workflow across all projects
- No Flags: Automatic detection means no need to remember flags
- Clean Output: Minimal, token-efficient output perfect for LLM contexts
For CI/CD
- Single Command: Replace multiple test commands with one
- Automatic Badge Updates: README badges stay up-to-date automatically
- Exit Codes: Returns non-zero exit code on test failures
For WASM Projects
- Seamless WASM Testing: No need to manually set
GOOS=js GOARCH=wasm
- Auto-Install Dependencies:
wasmbrowsertest installed automatically if needed
- Dual Testing: Run both stdlib and WASM tests in one command
Integration with devscripts
gotest integrates seamlessly with the devscripts workflow:
# In your project directory
./gotest.sh
This will execute gotest with proper directory detection and argument forwarding.
Quiet Mode (Default)
By default, gotest runs in quiet mode, filtering out:
- Passing test output (
=== RUN, --- PASS)
- Test log messages (
t.Log() output)
- Go warnings about matched packages
- Verbose wasmbrowsertest output
Only failures and the final summary are shown, making output ideal for:
- LLM token efficiency
- Quick CI/CD feedback
- Clean terminal output
Badge Integration
gotest automatically updates your README.md with badges for:
- License
- Go version
- Test status (Passing/Failed)
- Coverage percentage
- Race detection status
- Vet status
Badges are inserted in the BADGES_SECTION of your README.md.
Requirements
- Go 1.18 or later
- For WASM tests: A browser (Chrome, Firefox, or Safari)
License
MIT