Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active September 11, 2025 12:11
Show Gist options
  • Save Integralist/9fc9853ca099ff9164ab63388d461784 to your computer and use it in GitHub Desktop.
Save Integralist/9fc9853ca099ff9164ab63388d461784 to your computer and use it in GitHub Desktop.
Go Fuzz Testing
.PHONY: test-fuzz
test-fuzz: ## Run fuzz tests
ifeq ($(strip $(GO_FUZZARGS)),)
@status=0; \
for pkg in $$(go list ./...); do \
for test in $$(go test -list=^Fuzz $$pkg | grep '^Fuzz'); do \
echo ">>> Fuzzing $$pkg $$test"; \
if ! go test -fuzz=$$test -fuzztime=10s $$pkg; then \
echo "❌ FAIL: $$pkg $$test"; \
status=1; \
fi; \
done; \
done; \
exit $$status
else
@# Running tests with fuzz arguments
go test -v -run='^$$' $(GO_FUZZARGS)
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment