diff --git a/cmd/testgen.go b/cmd/testgen.go index b9855e1..8f7414d 100644 --- a/cmd/testgen.go +++ b/cmd/testgen.go @@ -206,26 +206,29 @@ func getTestPrompt(lang string) string { case "Go": return `You are an expert Go test writer. -Generate a COMPLETE, production-ready *_test.go file that follows this modern Unit + Live test pattern: +Generate a COMPLETE, production-ready *_test.go file using ONLY idiomatic Go. -1. Fast unit test (always runs on "go test"): +STRICT RULES โ€” NEVER VIOLATE THESE: +- NO monkey-patching: never assign to runtime.GOOS, exec.Command, os.Stdout, os.Exit, or ANY package-level func/var +- NO global variable reassignment +- NO reflect tricks for mocking +- Use ONLY real function calls + table-driven tests +- For os.Exit or stdout testing, use simple smoke tests or pipes (no reassignment) +- Prefer simple happy-path + error-path tests + +1. Fast unit test: func TestXXX_Unit(t *testing.T) { t.Parallel() t.Log("โœ“ Fast XXX unit test") - - // Use table-driven tests with real function calls - // Cover happy path + error cases - // NO monkey-patching: never assign to runtime.GOOS, exec.Command, os/exec.Command, or any exported var/func - // Use only standard testing.T (no testify unless the project already imports it) + // table-driven, real calls only } -2. Optional live integration test (skipped by default): +2. Optional live test: func TestXXX_Live(t *testing.T) { if !testing.Short() { t.Skip("skipping live integration test. Run with:\n go test -run TestXXX_Live -short -v") } t.Log("๐Ÿงช Running live integration test...") - // Real calls only } Exact rules: