Cline rules
.clinerules/testing-stratergy.mdGuides Cline to generate comprehensive test suites alongside code — covering TDD workflows, test pyramid strategy, framework patterns, and coverage analysis.
Cline rules
Quality
77/100
Scores the file, not the repository.Length
963 words
18 headings · 6 code blocksRepository
580
— · pushed 143 days agoLast changed
3 days ago
First indexed 3 days ago.123456789101112131415161718192021222324252627# Testing Strategy & Test Generation Protocol2829## Objective3031Guide Cline to proactively generate, maintain, and improve test suites as a first-class development activity — not an afterthought. Testing is infrastructure: once embedded into CI/CD pipelines, it becomes the backbone of project reliability.3233---3435## Core Directive3637You **MUST** treat tests as mandatory deliverables. When generating or modifying code, you **SHOULD** generate or update corresponding tests unless the user explicitly opts out.3839Before using `attempt_completion`, verify:4041- [ ] New/modified code has corresponding test coverage42- [ ] Tests pass (or user has been informed of expected failures)43- [ ] Edge cases and error paths are covered4445---4647## 1. Test Pyramid Strategy4849Follow the test pyramid to allocate effort appropriately:5051```52 / E2E \ <- Few, slow, high-confidence53 /----------\54 / Integration \ <- Moderate, test boundaries55 /----------------\56 / Unit Tests \ <- Many, fast, isolated57 /____________________\58```5960### Unit Tests (Foundation — 70% of tests)6162- Test individual functions, methods, and classes in isolation63- Mock external dependencies (databases, APIs, file system)64- **MUST** be fast (< 100ms each)65- **MUST** be deterministic — no flaky tests6667### Integration Tests (Middle — 20% of tests)6869- Test interactions between modules, services, or layers70- Use real dependencies where practical (test databases, in-memory stores)71- Verify API contracts, database queries, and service boundaries7273### End-to-End Tests (Top — 10% of tests)7475- Test critical user journeys through the full stack76- Use sparingly — they are slow and brittle77- Focus on happy paths and critical business flows7879---8081## 2. Test-Driven Development (TDD) Workflow8283When the user requests TDD or when building new features:8485```861. RED -> Write a failing test that defines the desired behavior872. GREEN -> Write the minimum code to make the test pass883. REFACTOR -> Clean up code while keeping tests green894. REPEAT90```9192**MUST** present each step clearly to the user. Do not skip ahead.9394---9596## 3. Framework-Specific Patterns9798### JavaScript/TypeScript (Jest / Vitest)99100```typescript101describe('UserService', () => {102 describe('createUser', () => {103 it('should create a user with valid input', async () => {104 const user = await userService.createUser({105 name: 'Alice',106 email: 'alice@example.com',107 });108 expect(user.id).toBeDefined();109 expect(user.name).toBe('Alice');110 });111112 it('should throw on duplicate email', async () => {113 await userService.createUser({name: 'Alice', email: 'alice@example.com'});114 await expect(115 userService.createUser({name: 'Bob', email: 'alice@example.com'}),116 ).rejects.toThrow('Email already exists');117 });118119 it('should reject invalid email format', async () => {120 await expect(121 userService.createUser({name: 'Alice', email: 'not-an-email'}),122 ).rejects.toThrow('Invalid email');123 });124 });125});126```127128### Python (pytest)129130```python131import pytest132from services.user_service import UserService133134class TestUserService:135 def test_create_user_with_valid_input(self, user_service):136 user = user_service.create_user(name="Alice", email="alice@example.com")137 assert user.id is not None138 assert user.name == "Alice"139140 def test_create_user_duplicate_email_raises(self, user_service):141 user_service.create_user(name="Alice", email="alice@example.com")142 with pytest.raises(ValueError, match="Email already exists"):143 user_service.create_user(name="Bob", email="alice@example.com")144145 def test_create_user_invalid_email_raises(self, user_service):146 with pytest.raises(ValueError, match="Invalid email"):147 user_service.create_user(name="Alice", email="not-an-email")148```149150### C# (xUnit)151152```csharp153public class UserServiceTests154{155 [Fact]156 public async Task CreateUser_WithValidInput_ReturnsUser()157 {158 var service = new UserService(mockRepo.Object);159 var user = await service.CreateUserAsync("Alice", "alice@example.com");160 Assert.NotNull(user.Id);161 Assert.Equal("Alice", user.Name);162 }163164 [Fact]165 public async Task CreateUser_DuplicateEmail_ThrowsException()166 {167 var service = new UserService(mockRepo.Object);168 await service.CreateUserAsync("Alice", "alice@example.com");169 await Assert.ThrowsAsync<DuplicateEmailException>(170 () => service.CreateUserAsync("Bob", "alice@example.com"));171 }172}173```174175---176177## 4. What to Test — Mandatory Coverage Areas178179For every function or module, **MUST** consider:180181| Category | Examples |182| --------------------- | ------------------------------------------------------------- |183| **Happy path** | Valid inputs produce expected outputs |184| **Edge cases** | Empty strings, zero, null, boundary values, max-length |185| **Error handling** | Invalid inputs, network failures, timeouts, permission errors |186| **State transitions** | Before/after mutations, side effects |187| **Concurrency** | Race conditions, parallel execution (when applicable) |188189---190191## 5. Mocking & Test Doubles Strategy192193- **MUST** mock external services (APIs, databases, file system) in unit tests194- **SHOULD** use dependency injection to make code testable195- **MUST NOT** mock the system under test — only its dependencies196- **SHOULD** prefer fakes over mocks when the dependency is complex197198```199Stub -> Returns canned data (simplest)200Mock -> Verifies interactions (use sparingly)201Fake -> Simplified working implementation (e.g., in-memory DB)202Spy -> Records calls for later assertion203```204205---206207## 6. Test Quality Checklist208209Before completing any testing task, verify:210211- [ ] **Descriptive names**: Test names describe the scenario, not the implementation (`should_reject_expired_token` not `test1`)212- [ ] **Arrange-Act-Assert**: Each test follows the AAA pattern clearly213- [ ] **One assertion per concept**: Tests verify one behavior (multiple `expect` calls are fine if they verify one logical outcome)214- [ ] **No test interdependence**: Tests can run in any order215- [ ] **No hardcoded sleep/delays**: Use polling, events, or test clocks216- [ ] **Meaningful assertions**: Assert specific values, not just "no error thrown"217218---219220## 7. Coverage Analysis221222When asked about coverage or when completing a testing task:223224- **SHOULD** suggest running coverage tools (`jest --coverage`, `pytest --cov`, `dotnet test --collect:"XPlat Code Coverage"`)225- **Target**: 80%+ line coverage for business logic, 90%+ for critical paths226- **MUST NOT** chase 100% — focus on meaningful coverage, not vanity metrics227- Uncovered code **SHOULD** be flagged with rationale (e.g., "UI rendering — covered by E2E tests")228229---230231## 8. CI/CD Integration Guidance232233When setting up or advising on CI/CD:234235- Tests **MUST** run on every PR/push236- Fast unit tests run first; slow integration/E2E tests run after237- Failed tests **MUST** block merge238- Coverage reports **SHOULD** be posted as PR comments239- Flaky tests **MUST** be quarantined and fixed, not ignored240241---242243## 9. Test Documentation244245When adding/modifying/deleting tests, make sure that TEST_CATALOGUE is kept up to date.246247<!--248Enterprise Considerations:249- Team-wide configurable coverage thresholds enforced across all repositories250- Test health dashboards showing pass rates, flakiness trends, and coverage gaps251- Shared test fixture and pattern libraries distributed across teams252- Automated test quality scoring and team benchmark comparisons253-->254
Also in 8VIM/8VIM
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| 8VIM/8VIM.clinerules/MemoryBank.md · 580 | Cline rules | archperformancedocs | 52/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| JCodesMore/ai-website-cloner-template.clinerules · 31k | Cline rules | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| BryaanF/LiantPortfolio.clinerules/project-guidelines.md · 0 | Cline rules | buildstylearchgit+2 | 96/100 | 3 days ago | |
| lepinkainen/humanlog.clinerules/project-rules.md · 0 | Cline rules | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| u9401066/zotero-keeper.clinerules/50-pubmed-project.md · 7 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| u9401066/pubmed-search-mcp.clinerules/50-pubmed-project.md · 23 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| u9401066/zotero-keepervscode-extension/resources/repo-assets/pubmed-search-mcp/.clinerules/50-pubmed-project.md · 7 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| VaillerTeeter/HoshimiNest.clinerules/project-identity.md · 1 | Cline rules | setuparchtypesdo-not | 93/100 | yesterday | |
| blendsdk/codeops-mcp.clinerules/project.md · 0 | Cline rules | buildteststylearch+7 | 91/100 | 3 days ago |
