一键导入
gen-test
Generate test scaffolding for a Go file following oastools conventions. Usage: /gen-test <file.go> [function names...]
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate test scaffolding for a Go file following oastools conventions. Usage: /gen-test <file.go> [function names...]
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Prepare a release (phases 1-6). Usage: /prepare-release [version]. If version omitted, infers from conventional commits. Coordinates agents for review, runs prepare-release.sh, then enhances release notes with rich formatting.
Run corpus regression tests against real-world OpenAPI specs. Usage: /corpus-test [short]
Review unpushed commits before pushing for code quality, bugs, security issues, and error handling. Use when preparing to push commits, want pre-push code review, or need to validate changes before pushing. Runs comprehensive analysis using specialized review agents.
Publish a prepared release (phase 7). Usage: /publish-release <version>. Requires version argument. Wraps publish-release.sh for deterministic execution.
Run full validation suite (make check + gopls diagnostics) and report structured pass/fail. Usage: /quality-gate [package...]
Compare two OpenAPI spec versions, highlight breaking changes, and suggest migration steps
| name | gen-test |
| description | Generate test scaffolding for a Go file following oastools conventions. Usage: /gen-test <file.go> [function names...] |
Generate test scaffolding for Go files following oastools testing conventions.
Usage:
/gen-test parser/resolver.go - Generate tests for all exported functions/gen-test validator/validate.go ValidateSpec - Generate test for specific functionRead the specified file and identify:
Note: In the commands below,
$FILErefers to the path provided by the user when invoking the skill. For example, if the user runs/gen-test parser/resolver.go, then$FILE=parser/resolver.go.
# Check if test file already exists
# Example: parser/resolver.go -> parser/resolver_test.go
ls -la "${FILE%%.go}_test.go" 2>/dev/null
Look for existing test patterns in the same package:
# Find existing tests in the package
# Example: parser/resolver.go -> parser/*_test.go
ls -la $(dirname "$FILE")/*_test.go 2>/dev/null | head -5
Read 1-2 existing test files to understand:
testutil, require, assert)Create or append to the *_test.go file following these conventions:
github.com/stretchr/testify/require and asserttests := []struct{...} patternt.Run(tt.name, func(t *testing.T) {...})testutil.LoadSpec() for loading OAS fixturesfunc TestFunctionName(t *testing.T) {
tests := []struct {
name string
input InputType
want OutputType
wantErr bool
}{
{
name: "valid input returns expected output",
input: validInput,
want: expectedOutput,
},
{
name: "invalid input returns error",
input: invalidInput,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := FunctionName(tt.input)
if tt.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
assert.Equal(t, tt.want, got)
})
}
}
func TestTypeName_MethodName(t *testing.T) {
// Setup
obj := NewTypeName(...)
// Test cases
tests := []struct {
name string
// ...
}{
// ...
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// ...
})
}
}
Always include test cases for:
After generating, verify the tests compile:
go test -c ./path/to/package
Present the generated test scaffolding and ask if the user wants to:
go test -v ./path/to/package -run TestName)