-
Notifications
You must be signed in to change notification settings - Fork 3
MVP Testing Strategy
Garot Conklin edited this page Jan 17, 2025
·
1 revision
The testing strategy for Cursor Rules Dynamic follows a comprehensive approach to ensure reliability and maintainability. Our testing pyramid consists of:
- Unit Tests
- Integration Tests
- End-to-End Tests
- Performance Tests
- Overall Coverage: 100%
- Critical Paths: 100%
- Edge Cases: 100%
- Error Handling: 100%
- TextConverter
- TemplateService
- ProjectAnalyzer
- RuleValidator
suite('TextConverter Test Suite', () => {
let testFilePath: string;
let testFileUri: vscode.Uri;
setup(async () => {
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
assert.ok(workspaceFolder, 'No workspace folder found');
testFilePath = path.join(workspaceFolder.uri.fsPath, '.cursorrules.test');
testFileUri = vscode.Uri.file(testFilePath);
await fs.promises.writeFile(testFilePath, 'Test content');
});
teardown(async () => {
try {
await fs.promises.unlink(testFilePath);
} catch (e) {
// Ignore errors if file doesn't exist
}
});
test('should convert text to JSON format', async () => {
const result = await TextConverter.convertToJson('Test content');
assert.ok(result.languages.default, 'Should have default rules');
});
});- Command Registration
- File System Operations
- Template Management
- Rule Processing
suite('Extension Integration Test Suite', () => {
test('Extension activation should register all commands', async () => {
const commands = await vscode.commands.getCommands();
const requiredCommands = [
'cursor-rules-dynamic.showStatus',
'cursor-rules-dynamic.convertToJson',
'cursor-rules-dynamic.browseTemplates',
'cursor-rules-dynamic.scanProject'
];
requiredCommands.forEach(cmd => {
assert.ok(
commands.includes(cmd),
`Command ${cmd} should be registered`
);
});
});
});- Complete Workflows
- User Interactions
- Error Scenarios
- Recovery Paths
suite('End-to-End Test Suite', () => {
test('should complete full conversion workflow', async () => {
// Create test file
const content = 'Test rule content';
await createTestFile(content);
// Execute conversion
await vscode.commands.executeCommand(
'cursor-rules-dynamic.convertToJson',
testFileUri
);
// Verify result
const result = await vscode.workspace.fs.readFile(testFileUri);
const json = JSON.parse(result.toString());
assert.ok(json.languages.default.rules[0].description === content);
});
});- Large File Handling
- Multiple File Processing
- Memory Usage
- Response Times
suite('Performance Test Suite', () => {
test('should handle large files efficiently', async () => {
const largeContent = 'x'.repeat(1000000);
const startTime = process.hrtime();
await TextConverter.convertToJson(largeContent);
const [seconds, nanoseconds] = process.hrtime(startTime);
assert.ok(
seconds * 1000 + nanoseconds / 1000000 < 1000,
'Should process within 1 second'
);
});
});export async function run(): Promise<void> {
const mocha = new Mocha({
ui: 'tdd',
color: true,
timeout: 60000
});
const testsRoot = path.resolve(__dirname, './');
try {
const files = await glob('**/**.test.js', { cwd: testsRoot });
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
return new Promise<void>((resolve, reject) => {
mocha.run(failures => {
failures ? reject(new Error(`${failures} tests failed`)) : resolve();
});
});
} catch (err) {
console.error('Error loading test files:', err);
throw err;
}
}{
"scripts": {
"test:coverage": "c8 --reporter=lcov --reporter=text-summary npm run test"
}
}- Group related tests
- Clear test names
- Proper setup/teardown
- Isolated test cases
- Test one thing at a time
- Clear assertions
- Meaningful error messages
- Proper cleanup
- Regular updates
- Coverage monitoring
- Performance tracking
- Documentation updates
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm ci
- run: npm test
- run: npm run test:coverage- All tests passing
- Coverage thresholds met
- Performance benchmarks met
- No security issues
- Purpose
- Prerequisites
- Steps
- Expected results
- Coverage reports
- Performance metrics
- Error logs
- Test history
- More E2E tests
- Visual regression tests
- Load testing
- Security testing
- Better reporting
- Automated reviews
- Performance profiling
- Coverage analysis