diff --git a/cmd/testgen.go b/cmd/testgen.go index 73eb6b3..8452368 100644 --- a/cmd/testgen.go +++ b/cmd/testgen.go @@ -192,36 +192,35 @@ func removeSourceComments(content, lang string) string { func getTestPrompt(lang string) string { switch lang { case "Go": - return `You are an expert Go test writer for the Grokkit project. + return `You are an expert Go test writer. -Generate a COMPLETE, production-ready *_test.go file that follows this EXACT pattern from cmd/scaffold_test.go: +Generate a COMPLETE, production-ready *_test.go file that follows this modern Unit + Live test pattern: -1. Fast unit test (always runs on "make test"): - func TestXXX_Unit(t *testing.T) { // or just TestXXX if it fits better +1. Fast unit test (always runs on "go test"): + func TestXXX_Unit(t *testing.T) { // or TestCreateIniFile if it fits better t.Parallel() - t.Log("โœ“ Fast XXX unit test (no Grok API call)") + t.Log("โœ“ Fast XXX unit test") - // Zero API calls / network + // Zero external calls // Use t.TempDir() + os.Chdir with proper defer restore + error logging - // testify/assert + require - // Table-driven where sensible - // Cover main functions in the source file + // Use standard testing.T (add testify/assert only if the project already uses it) + // Cover happy path, errors, edge cases + // Table-driven where it makes sense } 2. Optional live integration test (skipped by default): func TestXXX_Live(t *testing.T) { if !testing.Short() { - t.Skip("skipping live Grok integration test. Run with:\n go test ./cmd -run TestXXX_Live -short -v") + t.Skip("skipping live integration test. Run with:\n go test -run TestXXX_Live -short -v") } - t.Log("๐Ÿงช Running live Grok integration test...") - // Real Grok API calls via grok.NewClient() - // t.Logf messages so it never looks hung + t.Log("๐Ÿงช Running live integration test...") + // Real behavior (file I/O, exec, API calls, etc.) + // Use t.Logf messages so it never looks hung } Exact rules: -- Derive test name from source filename (e.g. client.go โ†’ TestClient_Unit / TestClient_Live) -- The XXX in the t.Skip command MUST match the live test function name you actually created -- Match Grokkit style exactly: imports, helpers, error handling, cwd restore +- Derive sensible test names from the source filename and functions (e.g. filer.go โ†’ TestCreateIniFile_Unit / TestCreateIniFile_Live) +- The XXX in the t.Skip command MUST exactly match the live test function name you created - t.Parallel() on unit tests only - NO unused imports - Return ONLY the full test file. No explanations, no markdown, no backticks, no extra text whatsoever.` diff --git a/cmd/testgen_test.go b/cmd/testgen_test.go index b0f1449..d3e1188 100644 --- a/cmd/testgen_test.go +++ b/cmd/testgen_test.go @@ -108,7 +108,7 @@ func TestGetTestPrompt(t *testing.T) { lang string wantPrefix string }{ - {"Go", "You are an expert Go test writer for the Grokkit project."}, + {"Go", "You are an expert Go test writer."}, // โ† updated to match the new generalized prompt {"Python", "You are a pytest expert."}, {"C", "You are a C unit testing expert using Check framework."}, {"C++", "You are a Google Test expert."},