Load comprehensive Go testing documentation with adaptive project analysis and framework detection
<codex_skill_adapter>
$context-testing-context-load-testing-go.$context-testing-context-load-testing-go as {{SC_ARGS}}.{{SC_ARGS}} as empty.spawn_agent(...) patterns to Codex spawn_agent(...).update_plan.config.toml when the original command mentions MCP.context:testing:context-load-testing-go.$context-testing-context-load-testing-go.STEP 1: Initialize comprehensive Go testing context session
/tmp/go-testing-context-$SESSION_ID.json{
"sessionId": "$SESSION_ID",
"timestamp": "ISO_8601_TIMESTAMP",
"phase": "initialization",
"performance_metrics": {
"start_time": "ISO_8601_TIMESTAMP",
"phase_timings": {},
"agent_completion_times": {},
"total_duration": null
},
"go_project_analysis": {
"modules_count": "auto-detect",
"test_files_count": "auto-detect",
"testing_frameworks": [],
"go_version": "auto-detect",
"complexity_level": "unknown"
},
"documentation_sources": {},
"focus_areas": [],
"context_optimization": {},
"checkpoints": {},
"error_recovery": {
"failed_operations": [],
"recovery_attempts": [],
"partial_completions": []
}
}
/tmp/go-testing-context-$SESSION_ID/STEP 2: Go project structure analysis and testing framework detection
Think deeply about the optimal context loading strategy based on the detected Go project characteristics and testing patterns.
IF complexity appears high (>50 test files OR multiple frameworks):
Think harder about enterprise Go testing architecture patterns and optimal sub-agent coordination strategies
ANALYZE project structure from Context section
DETERMINE testing complexity and framework usage patterns
IDENTIFY testing scope and specialization requirements
ASSESS current testing maturity and coverage level
IF Test files > 50 AND multiple frameworks detected:
ELSE IF Test files > 10 AND testify or other frameworks detected:
ELSE:
STEP 3: Adaptive documentation loading strategy
TRY:
IF complexity_level == "enterprise":
USE spawn_agent tool for comprehensive parallel documentation loading:
/tmp/go-testing-context-$SESSION_ID/stdlib-deep-dive.json/tmp/go-testing-context-$SESSION_ID/framework-mastery.json/tmp/go-testing-context-$SESSION_ID/performance-testing.json/tmp/go-testing-context-$SESSION_ID/testing-architecture.json/tmp/go-testing-context-$SESSION_ID/advanced-patterns.jsonELSE IF complexity_level == "moderate":
Go Testing Package Documentation
Testify Framework Documentation
https://github.com/stretchr/testifyTable-Driven Testing Patterns
https://go.dev/wiki/TableDrivenTestsGo Testing Blog and Best Practices
https://go.dev/blog/ELSE:
Standard Go Testing Basics
https://pkg.go.dev/testingGo Testing Tutorial
https://go.dev/doc/tutorial/add-a-testCATCH (documentation_loading_failed):
CATCH (sub_agent_coordination_failed):
STEP 4: Go-specific testing context organization and synthesis
CASE detected_frameworks: WHEN "testify":
WHEN "ginkgo" OR "gomega":
WHEN "standard":
WHEN "multiple":
STEP 5: Testing methodology and patterns synthesis
ORGANIZE loaded context by Go testing domains:
SYNTHESIZE project-specific guidance:
STEP 6: Multi-phase testing implementation guidance
{
"phase_1": {
"name": "Foundation Testing Setup",
"duration": "1-2 weeks",
"deliverables": ["Basic test structure", "Table-driven test patterns", "Coverage baseline"],
"success_criteria": ["Tests run successfully", "Coverage > 70%"],
"go_focus": ["Standard library testing", "Test organization", "Basic benchmarks"]
},
"phase_2": {
"name": "Advanced Testing Patterns",
"duration": "2-3 weeks",
"deliverables": ["Mock integration", "Integration tests", "Performance tests"],
"success_criteria": ["Mock coverage complete", "Integration tests pass"],
"go_focus": ["Interface mocking", "HTTP testing", "Parallel test execution"]
},
"phase_3": {
"name": "Testing Excellence",
"duration": "1-2 weeks",
"deliverables": ["CI/CD integration", "Advanced benchmarks", "Test documentation"],
"success_criteria": ["Automated testing pipeline", "Performance baselines established"],
"go_focus": ["Race detection", "Build constraints", "Test optimization"]
}
}
STEP 7: State management and comprehensive artifact creation
/tmp/go-testing-context-$SESSION_ID/comprehensive-guide.md/tmp/go-testing-context-$SESSION_ID/testing-checklist.md/tmp/go-testing-context-$SESSION_ID/go-examples//tmp/go-testing-context-$SESSION_ID/framework-guide.md/tmp/go-testing-context-$SESSION_ID/architecture-decisions.md/tmp/go-testing-context-$SESSION_ID/performance-metrics.jsonSTEP 8: Advanced Go testing enhancement for complex projects
IF complexity_level == "enterprise" AND multiple sub-agents used:
STEP 9: Quality assurance and Go-specific validation
TRY:
CATCH (validation_failed):
FINALLY:
/tmp/go-testing-temp-$SESSION_ID-*CASE complexity_level: WHEN "enterprise":
WHEN "moderate":
https://pkg.go.dev/testing)https://github.com/stretchr/testify)https://go.dev/wiki/TableDrivenTests)https://go.dev/blog/)WHEN "basic":
https://go.dev/doc/tutorial/add-a-test)https://pkg.go.dev/testing)Standard Library Focus:
Testify Integration:
Ginkgo/Gomega BDD Testing:
GoMock Advanced Patterns:
Advanced Table-Driven Test Pattern:
// Enterprise-grade table-driven testing with comprehensive coverage
func TestAdvancedUserValidation(t *testing.T) {
tests := []struct {
name string
input User
setupMocks func(*MockUserService)
expectedError error
expectedUser *User
validateFunc func(t *testing.T, result *User, err error)
}{
{
name: "valid user with all fields",
input: User{
Email: "[email protected]",
Username: "testuser",
Age: 25,
},
setupMocks: func(m *MockUserService) {
m.EXPECT().
ValidateEmail("[email protected]").
Return(true, nil).
Times(1)
},
expectedError: nil,
validateFunc: func(t *testing.T, result *User, err error) {
assert.NoError(t, err)
assert.Equal(t, "[email protected]", result.Email)
assert.True(t, result.Validated)
},
},
// Additional test cases...
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Setup
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockService := NewMockUserService(ctrl)
if tt.setupMocks != nil {
tt.setupMocks(mockService)
}
validator := NewUserValidator(mockService)
// Execute
result, err := validator.Validate(tt.input)
// Verify
if tt.validateFunc != nil {
tt.validateFunc(t, result, err)
} else {
assert.Equal(t, tt.expectedError, err)
assert.Equal(t, tt.expectedUser, result)
}
})
}
}
Comprehensive Benchmark Testing:
// Advanced benchmarking with memory allocation tracking
func BenchmarkUserProcessing(b *testing.B) {
benchmarks := []struct {
name string
userCount int
setupFunc func() []User
}{
{
name: "small dataset",
userCount: 100,
setupFunc: generateSmallUsers,
},
{
name: "large dataset",
userCount: 10000,
setupFunc: generateLargeUsers,
},
}
for _, bm := range benchmarks {
b.Run(bm.name, func(b *testing.B) {
users := bm.setupFunc()
processor := NewUserProcessor()
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
// Prevent compiler optimization
_ = processor.ProcessUsers(users)
}
})
}
}
// Memory allocation benchmark
func BenchmarkUserAllocation(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
user := &User{
Email: "[email protected]",
Username: "testuser",
Settings: make(map[string]string),
}
// Simulate realistic usage
user.Settings["theme"] = "dark"
_ = user.Validate()
}
}
HTTP Testing with Advanced Patterns:
// Comprehensive HTTP handler testing
func TestAdvancedUserHandler(t *testing.T) {
tests := []struct {
name string
method string
path string
body interface{}
setupMocks func(*MockUserService)
expectedStatus int
expectedBody interface{}
headers map[string]string
validateFunc func(t *testing.T, resp *httptest.ResponseRecorder)
}{
{
name: "create user success",
method: "POST",
path: "/users",
body: User{
Email: "[email protected]",
Username: "testuser",
},
setupMocks: func(m *MockUserService) {
m.EXPECT().
CreateUser(gomock.Any()).
Return(&User{ID: 1, Email: "[email protected]"}, nil)
},
expectedStatus: http.StatusCreated,
headers: map[string]string{
"Content-Type": "application/json",
},
validateFunc: func(t *testing.T, resp *httptest.ResponseRecorder) {
var user User
err := json.Unmarshal(resp.Body.Bytes(), &user)
assert.NoError(t, err)
assert.Equal(t, int64(1), user.ID)
assert.Equal(t, "[email protected]", user.Email)
},
},
// Additional test cases...
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Setup
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockService := NewMockUserService(ctrl)
if tt.setupMocks != nil {
tt.setupMocks(mockService)
}
handler := NewUserHandler(mockService)
// Prepare request
var bodyReader io.Reader
if tt.body != nil {
bodyBytes, _ := json.Marshal(tt.body)
bodyReader = bytes.NewReader(bodyBytes)
}
req := httptest.NewRequest(tt.method, tt.path, bodyReader)
for key, value := range tt.headers {
req.Header.Set(key, value)
}
resp := httptest.NewRecorder()
// Execute
handler.ServeHTTP(resp, req)
// Verify
assert.Equal(t, tt.expectedStatus, resp.Code)
if tt.validateFunc != nil {
tt.validateFunc(t, resp)
}
})
}
}
Code Quality Requirements:
go test -cPerformance Considerations:
go test -raceIntegration Standards:
After executing this command, you will have comprehensive, project-adapted context on:
Go Testing Fundamentals:
Advanced Go Testing Techniques:
Framework Integration Mastery:
Testing Architecture and Organization:
Project-Specific Optimization:
The context loading intelligently adapts to your specific Go project structure and emphasizes the most relevant testing documentation areas for your current development needs, ensuring maximum relevance and practical applicability.
State Files Created:
/tmp/go-testing-context-$SESSION_ID.json - Main session state and project analysis/tmp/go-testing-context-$SESSION_ID/ - Context workspace with organized documentation/tmp/go-testing-context-cache-$SESSION_ID.json - Documentation cache for performance/tmp/go-testing-patterns-$SESSION_ID.json - Detected patterns and recommendationsEnhanced State Schema:
{
"sessionId": "$SESSION_ID",
"timestamp": "ISO_8601_TIMESTAMP",
"phase": "initialization|analysis|loading|synthesis|complete",
"go_project_analysis": {
"modules_count": "number",
"test_files_count": "number",
"benchmark_functions": "number",
"example_functions": "number",
"detected_frameworks": ["testify", "ginkgo", "standard"],
"go_version": "1.21",
"module_path": "github.com/user/project",
"complexity_level": "basic|moderate|enterprise"
},
"documentation_loaded": {
"go_testing_pkg": "loaded|failed|skipped",
"testify_framework": "loaded|failed|skipped",
"table_driven_patterns": "loaded|failed|skipped",
"go_testing_blog": "loaded|failed|skipped",
"benchmark_guidance": "loaded|failed|skipped",
"http_testing": "loaded|failed|skipped"
},
"focus_areas": [
"fundamentals",
"table_driven_testing",
"subtests",
"benchmarking",
"mocking",
"integration_testing",
"coverage_analysis",
"advanced_patterns"
],
"context_optimization": {
"project_specific_patterns": [],
"framework_recommendations": [],
"performance_considerations": [],
"testing_architecture_guidance": []
},
"checkpoints": {
"project_analysis_complete": "boolean",
"documentation_loaded": "boolean",
"context_synthesized": "boolean",
"artifacts_created": "boolean",
"session_archived": "boolean"
}
}