IdiomarkD Testing Guide
Comprehensive testing approach for IdiomarkD (Idiomark for Developers) implementation.
Testing Strategy
Unit Tests
Location: packages/core/src/__tests__/
| Test Suite | Purpose | Status |
|---|---|---|
| migration-idiomarkd.test.ts | Backward compatibility Idiomark → IdiomarkD | ✅ |
| extraction-idiomarkd.test.ts | Behavioral analysis from code samples | ✅ |
| integration-idiomarkd.test.ts | Platform-agnostic integration | ✅ |
| scenarios-idiomarkd.test.ts | Behavioral scenario validation | ✅ |
Running Tests
# Run all tests
npm test
# Run specific test suite
npm test -- packages/core/src/__tests__/scenarios-idiomarkd.test.ts
# Run with coverage
npm run test:coverage
Integration Tests
HTTP API Testing
The IdiomarkD API server runs on port 4000.
# Start the server
cd packages/idiomarkd-api
pnpm dev
Health Check:
curl http://localhost:4000/health
# Expected: {"status":"ok","service":"idiomarkd-api","version":"1.0.0","timestamp":"..."}
Analyze Endpoint:
curl -X POST http://localhost:4000/api/v1/analyze \
-H "Content-Type: application/json" \
-d '{"code_samples":[{"filePath":"test.ts","content":"const x = 1","language":"typescript"}]}'
Expected Response:
- Status: 200
- Body contains
behavioral,confidence,sampleCount,meta
Error Cases:
# Missing code_samples
curl -X POST http://localhost:4000/api/v1/analyze \
-H "Content-Type: application/json" \
-d '{}'
# Expected: {"error":"code_samples array required","statusCode":400}
# Too many samples
curl -X POST http://localhost:4000/api/v1/analyze \
-H "Content-Type: application/json" \
-d '{"code_samples":['$(seq 1 101 | xargs -I{} echo '{"filePath":"test{}.ts","content":"x"}' | tr '\n' ',')']}'
# Expected: {"error":"max 100 samples per request","statusCode":400}
Web Playground Testing
-
Start all services:
# Terminal 1: Web app
cd web && pnpm dev
# Terminal 2: IdiomarkD API
cd packages/idiomarkd-api && pnpm dev -
Test cases:
- Empty input shows validation error
- Single file analyzes correctly
- Multiple files work
- Results display in all tabs
- Export button works
- Loading states show correctly
Manual Testing Checklist
1. Code Sample Extraction
- Extract from public repository
- Extract from private repository
- Extract with custom sample size
- Extract with specific file extensions
- Extract excluding test files
- Verify error handling for missing repos
2. Behavioral Analysis
- Verify cognitive style detection
- Check code structure calculation
- Validate naming convention extraction
- Review error handling patterns
- Analyze testing approach
- Check code review style
3. Profile Validation
- Validate against IdiomarkD schema
- Check required fields present
- Verify confidence scores 0-1
- Check enum values are valid
- Validate behavioral layer completeness
4. Editor Integrations
- VS Code: Load profile, check status bar, apply transformation
- Cursor: Load profile, verify prompt injection
- Copilot: Check configuration injection (limited API)
Scenario Testing
Cognitive Styles
| Style | Expected Code | Test Case |
|---|---|---|
| iterative_refinement | Loops with gradual refinement | ✅ |
| divide_conquer | Modular functions | ✅ |
| mvp_first | Simple implementation first | ✅ |
| spike_first | Experimental prototypes | ⏳ |
Code Structures
| Preference | Expected Pattern | Test Case |
|---|---|---|
| High functional (0.7+) | .map(), .filter() | ✅ |
| Low functional (0.3-) | For loops | ✅ |
Short functions (<20) | Single-purpose functions | ✅ |
Naming Conventions
| Convention | Variables | Types | Constants |
|---|---|---|---|
| camelCase | userName | UserService | MAX_RETRIES |
| PascalCase | UserName | UserService | MaxRetries |
| UPPER_SNAKE | USER_NAME | USER_SERVICE | MAX_RETRIES |
Error Handling
| Philosophy | Pattern | Test Case |
|---|---|---|
| graceful_degradation | try-catch with returns | ✅ |
| fail_fast | Early validation throws | ✅ |
| defensive | Null checks everywhere | ⏳ |
Testing Approaches
| Temperament | Expected Pattern | Test Case |
|---|---|---|
| pragmatic_not_zealous | Core path tests | ✅ |
| tdd_zealot | Full coverage with mocks | ✅ |
| exploratory | Tests during development | ⏳ |
Validation Criteria
Successful Test
- ✅ All tests pass
- ✅ Confidence scores are reasonable (> 0.5)
- ✅ Behavioral dimensions match manual inspection
- ✅ Profile validates without errors
Needs Investigation
- ⚠️ Low confidence (
< 0.5) - ⚠️ Inconsistent patterns across samples
- ⚠️ Test failures with valid profiles
Real Developer Validation
Preparation
-
Create Test Plan
- Define testing scenarios
- Prepare test repositories
- Set success criteria
-
Recruit Testers
- Target 3-5 developers
- Vary experience levels
- Include different specialties
-
Generate Initial Profiles
- Extract from public code
- Create IdiomarkD files
- Document confidence levels
-
Conduct Study
- 2-week testing period
- Daily feedback mechanism
- Weekly check-ins
-
Analyze Results
- Compare generated vs expected
- Collect qualitative feedback
- Document discrepancies
Success Metrics
- ✅ Generated code "feels like mine" > 80%
- ✅ Behavioral preferences accurate > 70%
- ✅ Would use in production > 60%
- ✅ Overall satisfaction > 3.5/5
Issue Tracking
Document issues found during testing:
| Issue | Severity | Description | Resolution |
|---|---|---|---|
| Low confidence | High | Too few samples | Increase sample size |
| Wrong patterns | Medium | Analysis error | Check algorithm |
| Validation errors | Low | Schema mismatch | Update validator |
| Performance | High | Slow extraction | Optimize AST |
Test Data
Sample Repositories
Use for testing:
Public Repos:
- https://github.com/torvalds/linux - C, moderate size
- https://github.com/torvalds/typescript - TypeScript, large
- https://github.com/vitejs/vite - Modern patterns
- https://github.com/facebook/react - Popular framework
Test Account:
- Create dedicated GitHub account for testing
- Use test repos to avoid conflicts
Continuous Integration
Add to CI/CD pipeline:
# .github/workflows/test-idiomarkd.yml
name: Test IdiomarkD
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install
- run: npm test