Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# CRITICAL TEST SUITE RULES

## CODE STYLE GUIDELINES
Must follow Windsor CLI style guidelines in STYLE.md:
1. Package Structure
2. Documentation Style
3. Testing Patterns
4. Code Organization

## MANDATORY TEST SUITE STRUCTURE
1. TEMPLATE FIRST
- Must show complete test suite structure with all t.Run() stubs
- Must get explicit user confirmation
- Must not proceed without confirmation

2. IMPLEMENTATION SEQUENCE
- Must implement one t.Run() at a time
- Must verify each implementation
- Must get user confirmation before next t.Run()
- Must never implement multiple tests at once
- Must show proposed test case before implementation
- Must get approval for each test case before coding
- Must run and verify each test before proceeding

3. SOURCE CODE RULES
- Must not modify source code during test routines
- Must alert user of source code bugs
- Must follow Windsor CLI style guidelines
- Must use standard Go testing package (no testify)

4. VERIFICATION CHECKLIST
- Must run test after each t.Run() implementation
- Must report test results
- Must get user confirmation before proceeding

## VALIDATION REQUIREMENTS
Before Implementation:
- Confirm test suite structure is complete
- Get user approval of structure
- Verify no source code modifications planned
- Get approval for first test case to implement

During Implementation:
- Show proposed test case
- Get approval for test case
- Implement one test at a time
- Verify each test
- Get user confirmation
- Report results
- Get approval for next test case

## TEST ENGINEER CAPABILITIES
1. Coverage Analysis
- Run: `go test -coverprofile=coverage.out ./pkg/[package]`
- Analyze: `go tool cover -func=coverage.out`
- Run suites: `go test ./pkg/[package]/... -v`
- Run individual: `go test ./pkg/[package]/... -run TestName`

2. Test Management
- Troubleshoot failing tests
- Improve test coverage
- Ensure style compliance

## AUDIO NOTIFICATIONS
Must use `say` command with Samantha voice for:
- Test Completion: "All tests are now passing"
- Test Failure: "Test failure detected in [test name]"
- Coverage Improvement: "Coverage improved to [percentage]"
- Source Code Bug: "Source code bug detected in [function]. Please review."
- User Input Needed: "User input required for [specific issue]"
- Work Complete: "Test engineering work complete"

## TASK TEMPLATES
When creating new code or modifying existing code, refer to:
1. BDD style tests: STYLE.md > Testing Patterns > BDD Style
2. Class headers: STYLE.md > Documentation Style > Class Headers
3. Section headers: STYLE.md > Documentation Style > Section Headers
4. Mock implementations: STYLE.md > Code Organization > Mock Implementation
5. Shims: STYLE.md > Code Organization > Shims
163 changes: 163 additions & 0 deletions .vscode/go.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"Main File": {
"prefix": "snippet-main",
"body": [
"package ${1:packageName}",
"",
"import (",
" ${2:// imports}",
")",
"",
"// The ${3:ClassName} is a ${4:brief description}",
"// It provides ${5:detailed explanation}",
"// ${6:role in application}",
"// ${7:key features/capabilities}",
"",
"// =============================================================================",
"// Types",
"// =============================================================================",
"",
"type ${3:ClassName} struct {",
" ${8:// fields}",
"}",
"",
"// =============================================================================",
"// Constructor",
"// =============================================================================",
"",
"// New${3:ClassName} creates a new ${3:ClassName} instance",
"func New${3:ClassName}(injector di.Injector) *${3:ClassName} {",
" return &${3:ClassName}{",
" ${9:// initialization}",
" }",
"}",
"",
"// =============================================================================",
"// Public Methods",
"// =============================================================================",
"",
"// ${10:MethodName} ${11:description}",
"func (c *${3:ClassName}) ${10:MethodName}() error {",
" ${12:// implementation}",
" return nil",
"}"
],
"description": "CLI main implementation file"
},
"Test File": {
"prefix": "snippet-test",
"body": [
"package ${1:packageName}",
"",
"import (",
" \"testing\"",
" ${2:// other imports}",
")",
"",
"// =============================================================================",
"// Test Setup",
"// =============================================================================",
"",
"type Mocks struct {",
" ${3:// mock fields}",
"}",
"",
"type SetupOptions struct {",
" ${4:// setup options}",
"}",
"",
"func setupMocks(t *testing.T, opts ...*SetupOptions) *Mocks {",
" t.Helper()",
" ${5:// setup implementation}",
" return &Mocks{}",
"}",
"",
"// =============================================================================",
"// Test Public Methods",
"// =============================================================================",
"",
"func Test${6:ComponentName}_${7:MethodName}(t *testing.T) {",
" setup := func(t *testing.T) (*${6:ComponentName}, *Mocks) {",
" t.Helper()",
" mocks := setupMocks(t)",
" obj := New${6:ComponentName}(mocks.Injector)",
" return obj, mocks",
" }",
"",
" t.Run(\"${8:Success}\", func(t *testing.T) {",
" // Given ${9:context}",
" mocks, obj := setup(t)",
" ",
" // When ${10:action}",
" err := obj.${11:MethodName}()",
" ",
" // Then no error should occur",
" if err != nil {",
" t.Errorf(\"Expected success, got error: %v\", err)",
" }",
" })",
"}"
],
"description": "CLI test file with setup and test case"
},
"Mock File": {
"prefix": "snippet-mock",
"body": [
"package ${1:packageName}",
"",
"import (",
" ${2:// imports}",
")",
"",
"// Mock${3:InterfaceName} is a mock implementation of the ${3:InterfaceName} interface",
"type Mock${3:InterfaceName} struct {",
" ${4:MethodName}Func func() error",
" ${5:// other function fields}",
"}",
"",
"// NewMock${3:InterfaceName} is a constructor for Mock${3:InterfaceName}",
"func NewMock${3:InterfaceName}() *Mock${3:InterfaceName} {",
" return &Mock${3:InterfaceName}{}",
"}",
"",
"// ${4:MethodName} calls the mock ${4:MethodName}Func if set, otherwise returns nil",
"func (m *Mock${3:InterfaceName}) ${4:MethodName}() error {",
" if m.${4:MethodName}Func != nil {",
" return m.${4:MethodName}Func()",
" }",
" return nil",
"}",
"",
"// Ensure Mock${3:InterfaceName} implements ${3:InterfaceName}",
"var _ ${3:InterfaceName} = (*Mock${3:InterfaceName})(nil)"
],
"description": "CLI mock implementation file"
},
"Section Header": {
"prefix": "snippet-section",
"body": [
"// =============================================================================",
"// ${1:SECTION NAME}",
"// ============================================================================="
],
"description": "CLI section header format"
},
"Test Case": {
"prefix": "snippet-test-case",
"body": [
"t.Run(\"${1:Scenario}\", func(t *testing.T) {",
" // Given ${2:context}",
" mocks, obj := setup(t)",
" ",
" // When ${3:action}",
" err := obj.${4:MethodName}()",
" ",
" // Then ${5:result}",
" if err != nil {",
" t.Errorf(\"Expected success, got error: %v\", err)",
" }",
"})"
],
"description": "CLI test case with BDD style"
}
}
Loading
Loading