Files
mev-beta/.opencode/commands/write-tests.md
2025-09-14 10:09:55 -05:00

2.1 KiB

Write Comprehensive Tests

Write comprehensive tests for the following functionality: $ARGUMENTS

Testing Framework:

  1. Test Planning: Design test cases for all scenarios
  2. Unit Testing: Implement unit tests with high coverage
  3. Integration Testing: Create integration tests for component interactions
  4. Property-Based Testing: Implement property-based tests for mathematical functions
  5. Fuzz Testing: Add fuzz tests for edge cases
  6. Benchmark Testing: Create benchmarks for performance-critical code

Testing Standards:

  • Coverage Targets: >90% for Go, >95% for Solidity, >85% for JavaScript
  • Test Organization: Follow language-specific testing conventions
  • Test Data: Use realistic test data and edge cases
  • Test Documentation: Document test scenarios and expected outcomes

Language-Specific Testing:

Go Testing

// Unit tests with table-driven approach
func TestFunctionName(t *testing.T) {
    tests := []struct {
        name     string
        input    InputType
        expected OutputType
        wantErr  bool
    }{
        // Test cases
    }
    
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            // Test implementation
        })
    }
}

Solidity Testing

// Property-based testing with Foundry
function testFuzz_ValidInputs_AlwaysWork(uint256 amount) public {
    vm.assume(amount > 0 && amount < type(uint128).max);
    // Test implementation
}

JavaScript Testing

// Vue component testing with Vitest
describe('ComponentName', () => {
  it('should render correctly', () => {
    // Test implementation
  })
})

Test Categories:

  • Happy Path: Tests for expected normal operation
  • Edge Cases: Tests for boundary conditions
  • Error Conditions: Tests for error handling
  • Security: Tests for potential vulnerabilities
  • Performance: Benchmarks for critical functions

Deliverables:

  • Comprehensive test suite with high coverage
  • Property-based tests for mathematical functions
  • Fuzz tests for edge cases
  • Benchmark tests for performance-critical code
  • Test documentation and scenarios