Files
managing-apps/.cursor/commands/update-test-todo.md

200 lines
6.1 KiB
Markdown

# update-test-todo
## When to Use
Use this command when you need to:
- Update TODO.md with current test results from a test project
- Analyze test failures and identify business logic issues
- Set priorities for fixing failing tests
- Track progress on unit test development and bug fixes
## Prerequisites
- Test project exists and is runnable
- TODO.md file exists in project root
- Tests can be executed with `dotnet test`
## Execution Steps
### Step 1: Run Tests and Capture Results
**Run the test project:**
```bash
cd src/YourTestProject
dotnet test --verbosity minimal | tail -20
```
**Expected output format:**
```
Passed! - Failed: X, Passed: Y, Skipped: Z, Total: T, Duration: D ms
```
### Step 2: Analyze Test Results
**Count by category:**
- Identify which test classes have the most failures
- Group failures by business logic area (Trading, P&L, Signals, etc.)
- Determine if failures indicate business logic bugs vs incorrect test expectations
**Example analysis:**
```
MoneyManagementTests: 8 failures
SignalProcessingTests: 9 failures
TraderAnalysisTests: 3 failures
TradingMetricsTests: 0 failures (✅ working)
```
### Step 3: Update TODO.md Structure
**Update test summary:**
```markdown
## Test Results Summary
**Total Tests:** T
- **Passed:** Y ✅
- **Failed:** X ❌ (Category1: A, Category2: B, ...)
```
**Update priority sections:**
- Mark completed items as ✅ FIXED
- Move next priority items to "High Priority - Next Focus"
- Update investigation steps for current priority
**Example:**
```markdown
### Critical Issues (High Priority) ✅ MOSTLY RESOLVED
1. **Volume Calculations**: ✅ FIXED - All TradingMetrics volume calculations working correctly
### High Priority - Next Focus
5. **Money Management Optimization**: SL/TP calculations have incorrect logic (8 failing tests)
```
### Step 4: Set Next Priority
**Choose next focus based on:**
- Business impact (trading logic > display logic)
- Number of failing tests
- Core vs peripheral functionality
**Priority order example:**
1. **Money Management** (8 fails) - Core trading strategy logic
2. **Signal Processing** (9 fails) - Trading signal generation
3. **Trader Analysis** (3 fails) - Performance evaluation
4. **P&L Tests** (2 fails) - Profit calculation edge cases
### Step 5: Update Investigation Steps
**For current priority, add specific debugging steps:**
```markdown
### Investigation Steps for [Current Priority]
1. **Debug [MethodName]()** - Check [specific logic area]
2. **Debug [Calculation]** - Verify [expected behavior]
3. **Debug [Edge Case]** - Ensure [boundary condition]
4. **Debug [Integration]** - Check [component interaction]
```
## Best Practices
### Test Status Tracking
-**Passed**: All tests in category working
- 🔄 **In Progress**: Currently being fixed
-**Pending**: Known issues, not yet addressed
-**Failed**: Tests failing, investigation needed
### Priority Setting
- **Critical**: Core trading calculations (P&L, volume, fees)
- **High**: Trading strategy logic (signals, money management)
- **Medium**: Performance evaluation (win rates, trader analysis)
- **Low**: Edge cases and display logic
### Business Logic vs Test Issues
- **Business Logic Bug**: Tests fail because implementation is wrong
- **Test Expectation Issue**: Tests fail because expectations don't match actual (correct) behavior
- **Test Setup Issue**: Tests fail due to incorrect test data or mocking
## Common Patterns
### Trading Logic Priority
1. **Money Management** - SL/TP optimization affects risk control
2. **Signal Processing** - Signal generation affects trade entries
3. **Volume/P&L Calculations** - Core metrics for performance analysis
4. **Fee Calculations** - Cost analysis for profitability
### Investigation Framework
```
1. **Reproduce Issue**: Run failing test individually
2. **Debug Implementation**: Add logging to understand actual behavior
3. **Compare Expectations**: Verify test assumptions vs business requirements
4. **Fix Implementation**: Update code if business logic is wrong
5. **Fix Tests**: Update test expectations if implementation is correct
6. **Add Edge Cases**: Ensure comprehensive coverage
```
## Example Execution
**User input:** Update TODO.md for Managing.Domain.Tests
**AI execution:**
1. **Run tests:**
```bash
cd src/Managing.Domain.Tests
dotnet test --verbosity minimal | tail -5
```
Output: `Failed: 22, Passed: 138, Skipped: 0, Total: 160`
2. **Analyze failures:**
- MoneyManagementTests: 8 fails
- SignalProcessingTests: 9 fails
- TraderAnalysisTests: 3 fails
- ProfitLossTests: 2 fails
3. **Update TODO.md:**
```markdown
## Test Results Summary
**Total Tests:** 160
- **Passed:** 138 ✅
- **Failed:** 22 ❌ (MoneyManagement: 8, SignalProcessing: 9, TraderAnalysis: 3, ProfitLoss: 2)
### High Priority - Next Focus
5. **Money Management Optimization**: SL/TP calculations have incorrect logic (8 failing tests)
```
4. **Set investigation steps:**
```markdown
### Investigation Steps for Money Management
1. **Debug GetBestSltpForPosition()** - Check candle filtering logic with next position
2. **Debug Price Movement Calculations** - Verify min/max price detection for SL/TP
3. **Debug Percentage Calculations** - Ensure GetPercentageFromEntry() works correctly
4. **Debug Averaging Logic** - Check how multiple positions are averaged
```
## Important Notes
- 📊 **Track Progress**: Update TODO.md after each significant fix
- 🎯 **Prioritize Impact**: Focus on core trading logic first
- 🔍 **Debug Thoroughly**: Understand root cause before fixing
- ✅ **Verify Fixes**: Ensure fixes don't break other tests
- 📈 **Comprehensive Coverage**: Add tests for edge cases found during debugging
## Quick Commands
**Update test results:**
```bash
cd src/YourTestProject && dotnet test --verbosity minimal | tail -5
```
**Run specific test category:**
```bash
dotnet test --filter "CategoryName" --verbosity normal
```
**Debug individual test:**
```bash
dotnet test --filter "FullyQualifiedTestName" --verbosity normal
```
**Generate coverage report:**
```bash
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
```