Test Coverage Analysis
Run Go tests with coverage profiling to identify untested code paths.
Usage
/coverage- Coverage for all packages/coverage ./internal/repo/...- Coverage for specific package
Steps
- Run tests with coverage
If $ARGUMENTS specifies a package:
```bash
go test -coverprofile=coverage.out -covermode=atomic -timeout 5m $ARGUMENTS 2>&1
```
Otherwise, run all packages:
```bash
go test -coverprofile=coverage.out -covermode=atomic -timeout 5m ./... 2>&1
```
- Generate coverage summary
```bash
go tool cover -func=coverage.out 2>&1
```
- Identify low-coverage packages
Parse the output and flag packages below 50% coverage.
- Report findings
```
## Coverage Results
### Package Summary
| Package | Coverage | Status |
|---------|----------|--------|
### Overall
- Total coverage: N%
### Low Coverage (< 50%)
- [packages needing attention]
### Uncovered Functions
- [key uncovered functions in critical packages]
```
- Cleanup
```bash
rm -f coverage.out
```
Critical Packages
Pay special attention to coverage in:
internal/repo/- Data access layerinternal/manager/- Orchestration logicinternal/index/- Search indexinginternal/search/- Search API handlers
Tips
- For HTML coverage visualization:
go tool cover -html=coverage.out -o coverage.html - Integration test coverage requires
-tags integrationand Docker - Test files (
_test.go) are excluded from coverage automatically