Skip to content

Commit 6caad33

Browse files
authored
Merge pull request #20 from Grazulex/copilot/fix-19
πŸ”„ Complete documentation and examples update - FINAL VERSION FOR PROD
2 parents c146ad5 + e371938 commit 6caad33

File tree

12 files changed

+1075
-163
lines changed

12 files changed

+1075
-163
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 160 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ The package enables a clean separation between experimental draft tests and prod
3434
- πŸ§ͺ Native Pest 3 support with proper test isolation
3535
- πŸ“‹ Automatic backup of configuration files before modification
3636
- πŸ”– Unique reference tracking for test promotion from draft to CI
37-
- πŸ“Š **NEW: Test status tracking** - Automatic tracking of test execution results and history
37+
- πŸ“Š **NEW: Comprehensive Test Status Tracking**
38+
- πŸ“ˆ Automatic tracking of test execution results and history
39+
- 🎯 Status persistence across test runs with `.status.json`
40+
- πŸ“‹ Historical tracking of test state changes
41+
- πŸ” Advanced test filtering and management by status
42+
- πŸ“… Timestamped audit trails for test evolution
43+
- βš™οΈ Configurable history limits and environment-specific settings
3844
- 🎯 Built for clean TDD workflow separation
3945
- πŸš€ Easy graduation path from draft tests to production test suite
46+
- πŸ”§ **Professional Test Management**: Advanced filtering, promotion, and audit capabilities
4047

4148
## πŸ”§ The Five-Command TDD Workflow
4249

@@ -68,11 +75,11 @@ graph LR
6875

6976
| Command | Role in TDD Flow | Description |
7077
|---------|------------------|-------------|
71-
| **`tdd:init`** | πŸ—οΈ **Setup** | Initialize TDDraft environment and configuration |
72-
| **`tdd:make`** | πŸ§ͺ **Red Phase** | Create a new failing test with unique tracking |
73-
| **`tdd:test`** | πŸ”„ **Red-Green Cycle** | Run and iterate on draft tests until they pass |
74-
| **`tdd:list`** | πŸ“‹ **Review** | List and manage your draft tests before promotion |
75-
| **`tdd:promote`** | πŸš€ **Graduate** | Move ready tests to production CI test suite |
78+
| **`tdd:init`** | πŸ—οΈ **Setup** | Initialize TDDraft environment and configuration with status tracking |
79+
| **`tdd:make`** | πŸ§ͺ **Red Phase** | Create a new failing test with unique tracking reference |
80+
| **`tdd:test`** | πŸ”„ **Red-Green Cycle** | Run and iterate on draft tests with automatic status tracking |
81+
| **`tdd:list`** | πŸ“‹ **Review** | List and manage draft tests with status history and filtering |
82+
| **`tdd:promote`** | πŸš€ **Graduate** | Move ready tests to production CI suite with audit trail |
7683

7784
### 🎯 Why This Flow Matters
7885

@@ -94,15 +101,15 @@ php artisan tdd:init
94101
php artisan tdd:make "User can register"
95102
php artisan tdd:make "Password validation" --type=unit
96103

97-
# 3. πŸ”„ RED-GREEN CYCLE: Iterate until tests pass
98-
php artisan tdd:test --filter="User can register" # RED: Test fails
104+
# 3. πŸ”„ RED-GREEN CYCLE: Iterate until tests pass (with automatic status tracking)
105+
php artisan tdd:test --filter="User can register" # RED: Test fails (status tracked)
99106
# Write minimal code to make test pass...
100-
php artisan tdd:test --filter="User can register" # GREEN: Test passes
107+
php artisan tdd:test --filter="User can register" # GREEN: Test passes (status tracked)
101108
# Refactor code...
102-
php artisan tdd:test --filter="User can register" # GREEN: Still passes
109+
php artisan tdd:test --filter="User can register" # GREEN: Still passes (status tracked)
103110

104-
# 4. πŸ“‹ REVIEW: Check all draft tests before promotion
105-
php artisan tdd:list --details
111+
# 4. πŸ“‹ REVIEW: Check all draft tests with their status history
112+
php artisan tdd:list --details # Shows current status and history for each test
106113

107114
# 5. πŸš€ GRADUATE: Move ready tests to CI suite
108115
php artisan tdd:promote tdd-20250718142530-Abc123
@@ -140,10 +147,12 @@ php artisan tdd:init
140147
```
141148

142149
This command will:
143-
- Create `tests/TDDraft/` directory structure
150+
- Create `tests/TDDraft/` directory structure with `.gitkeep`
144151
- Configure PHPUnit to separate TDDraft tests from main suite
145152
- Configure Pest to exclude TDDraft from default test runs
146-
- Optionally create example test files
153+
- Set up status tracking system for test execution monitoring
154+
- Create configuration file with environment-specific status tracking settings
155+
- Optionally create example test files for quick start
147156

148157
## πŸ›  Usage
149158

@@ -200,36 +209,38 @@ it('user can register', function (): void {
200209
->todo('Implement the test scenario for: user can register');
201210
```
202211

203-
### Run Tests Separately
212+
### Run Tests with Status Tracking
213+
214+
Laravel TDDraft provides dedicated commands with automatic status monitoring:
204215

205216
```bash
206-
# Run only main tests (excludes TDDraft)
217+
# Run only main tests (excludes TDDraft)
207218
pest
208219

209-
# Run only TDDraft tests (with automatic status tracking!)
220+
# Run only TDDraft tests with automatic status tracking
210221
php artisan tdd:test
211222

212-
# Run TDDraft tests with options
223+
# Run TDDraft tests with options (all with status tracking)
213224
php artisan tdd:test --filter="user registration"
214225
php artisan tdd:test --coverage
215226
php artisan tdd:test --parallel
216227
php artisan tdd:test --stop-on-failure
217228

229+
# Alternative: use pest directly (without automatic status tracking)
230+
pest --testsuite=tddraft
231+
218232
# Filter by type
219233
pest --testsuite=tddraft --group=feature
220234
pest --testsuite=tddraft --group=unit
221235

222236
# Filter by specific reference
223237
pest --testsuite=tddraft --group=tdd-20250718142530-Abc123
224238

225-
# Alternative: use pest directly
226-
pest --testsuite=tddraft
227-
228239
# Run all tests including TDDraft
229240
pest --testsuite=default,tddraft
230241
```
231242

232-
### Test Status Tracking (NEW)
243+
### Comprehensive Status Tracking System
233244

234245
Laravel TDDraft now automatically tracks your test execution results:
235246

@@ -241,11 +252,33 @@ php artisan tdd:test
241252
# Each test result is linked to its unique reference for precise tracking
242253
```
243254

244-
**Status tracking provides:**
245-
- Automatic recording of test results (passed/failed/error/skipped)
246-
- Historical tracking of status changes over time
247-
- Reference-based linking for audit trails
248-
- JSON storage for easy integration with other tools
255+
**Comprehensive status tracking features:**
256+
- βœ… **Automatic Recording**: Test results (passed/failed/error/skipped) saved after each run
257+
- πŸ“Š **Historical Tracking**: Maintains change history for test evolution analysis
258+
- πŸ”– **Reference-Based Linking**: Status tied to unique test references for audit trails
259+
- πŸ“ **JSON Storage**: Structured data for easy integration with external tools
260+
- βš™οΈ **Environment Configuration**: Customizable tracking behavior per environment
261+
- πŸ“ˆ **Test Stability Analysis**: Track which tests are ready for promotion based on status history
262+
263+
**Example status file structure:**
264+
```json
265+
{
266+
"tdd-20250718142530-Abc123": {
267+
"status": "passed",
268+
"updated_at": "2025-07-18T14:30:45+00:00",
269+
"history": [
270+
{
271+
"status": "failed",
272+
"timestamp": "2025-07-18T14:25:30+00:00"
273+
},
274+
{
275+
"status": "failed",
276+
"timestamp": "2025-07-18T14:27:15+00:00"
277+
}
278+
]
279+
}
280+
}
281+
```
249282

250283
### List and Manage Tests
251284

@@ -343,24 +376,37 @@ pest tests/Feature/Auth/UserRegistrationTest.php
343376
pest
344377
```
345378

346-
### Tracking Test Lineage
379+
### Status Tracking and Test Lineage
380+
381+
The unique reference system with status tracking allows you to:
382+
- **Track Test Evolution**: Monitor tests from draft to production with complete history
383+
- **Analyze Test Stability**: Use status history to determine promotion readiness
384+
- **Maintain Audit Trails**: Full traceability for compliance and debugging
385+
- **Link CI Failures**: Connect production failures back to original draft intent
386+
- **Data-Driven Decisions**: Use status data to optimize TDD workflow
387+
388+
**Advanced status analysis example:**
389+
```bash
390+
# Find tests that are consistently passing (ready for promotion)
391+
php artisan tdd:list --details | grep "βœ… Passed"
392+
393+
# Identify tests that need attention based on status history
394+
# (This could be automated using the .status.json data)
395+
```
347396

348-
The unique reference system allows you to:
349-
- Track which tests originated from TDDraft
350-
- Monitor test evolution from draft to production
351-
- Maintain audit trail for compliance
352-
- Link CI failures back to original draft intent
397+
## βš™οΈ Configuration
353398

354-
## πŸ“ Configuration
399+
### Status Tracking Configuration
355400

356-
The package configuration is published to `config/tddraft.php`:
401+
The package configuration is published to `config/tddraft.php` with comprehensive status tracking options:
357402

358403
```php
359404
return [
360405
/**
361406
* Test status tracking configuration
362407
*
363-
* NEW: Controls how test execution results are tracked and persisted.
408+
* Controls how test execution results are tracked and persisted.
409+
* This is a key feature that enables professional TDD workflow management.
364410
*/
365411
'status_tracking' => [
366412
// Enable or disable status tracking
@@ -378,47 +424,105 @@ return [
378424
];
379425
```
380426

381-
**Environment Variables:**
427+
### Environment-Specific Configuration
428+
429+
Configure different behavior per environment:
430+
382431
```env
383-
# Enable/disable status tracking
432+
# Development environment (.env.local)
384433
LARAVEL_TDDRAFT_STATUS_TRACKING_ENABLED=true
385-
386-
# Configure status file location
387434
LARAVEL_TDDRAFT_STATUS_FILE=tests/TDDraft/.status.json
388-
389-
# Control history tracking
390435
LARAVEL_TDDRAFT_TRACK_HISTORY=true
391-
LARAVEL_TDDRAFT_MAX_HISTORY=50
436+
LARAVEL_TDDRAFT_MAX_HISTORY=100
437+
438+
# Testing/CI environment (.env.testing)
439+
LARAVEL_TDDRAFT_STATUS_TRACKING_ENABLED=true
440+
LARAVEL_TDDRAFT_STATUS_FILE=tests/TDDraft/.status.testing.json
441+
LARAVEL_TDDRAFT_TRACK_HISTORY=false
442+
LARAVEL_TDDRAFT_MAX_HISTORY=20
443+
444+
# Production environment (.env.production)
445+
LARAVEL_TDDRAFT_STATUS_TRACKING_ENABLED=false
392446
```
393447

394448
## πŸ§ͺ Example Draft Test
395449

450+
**Example of a TDDraft test with unique reference tracking and status monitoring:**
451+
396452
```php
397453
<?php
398454

399455
declare(strict_types=1);
400456

401-
it('should fail initially - this is normal for TDDraft', function (): void {
457+
/**
458+
* TDDraft Test: User registration workflow
459+
*
460+
* Reference: tdd-20250718142530-Abc123
461+
* Type: feature
462+
* Created: 2025-07-18 14:25:30
463+
*/
464+
465+
it('should fail initially - this is normal for TDD red phase', function (): void {
402466
// This test intentionally fails to demonstrate the TDD "red" phase
403-
expect(false)->toBeTrue('This draft needs implementation!');
404-
})->group('tddraft', 'feature', 'example-red-phase');
467+
// Status will be tracked as 'failed' until implementation is complete
468+
469+
$response = $this->post('/register', [
470+
'name' => 'John Doe',
471+
'email' => '[email protected]',
472+
'password' => 'password',
473+
'password_confirmation' => 'password',
474+
]);
405475

406-
it('can be promoted when ready', function (): void {
407-
// When this passes, you can promote it to your main test suite
476+
$response->assertStatus(201);
477+
$this->assertDatabaseHas('users', [
478+
'email' => '[email protected]',
479+
]);
480+
})
481+
->group('tddraft', 'feature', 'tdd-20250718142530-Abc123')
482+
->todo('Implement user registration endpoint and validation');
483+
484+
it('can be promoted when ready and status shows consistent passing', function (): void {
485+
// When this test consistently passes (shown in status tracking),
486+
// it's ready for promotion to the main test suite
408487
expect(true)->toBeTrue();
409-
})->group('tddraft', 'feature', 'example-green-phase');
488+
})
489+
->group('tddraft', 'feature', 'tdd-20250718142530-Abc123');
410490
```
411491

412-
## πŸ“š Documentation
492+
**Key features demonstrated:**
493+
- βœ… **Unique Reference**: `tdd-20250718142530-Abc123` for tracking and promotion
494+
- πŸ“Š **Status Tracking**: Each run records pass/fail status with timestamp
495+
- πŸ”„ **TDD Cycle**: Start with failing test, implement code, achieve passing status
496+
- 🎯 **Promotion Ready**: Use status history to determine when test is stable
497+
498+
## πŸ“š Documentation & Examples
499+
500+
### Complete Documentation
413501

414502
For comprehensive documentation, see the [`docs/`](docs/) directory:
415503

416-
- [Installation Guide](docs/installation.md)
417-
- [Configuration](docs/configuration.md)
418-
- [Usage Guide](docs/usage.md)
419-
- [Commands Reference](docs/commands.md)
420-
- [Best Practices](docs/best-practices.md)
421-
- [Troubleshooting](docs/troubleshooting.md)
504+
- [Installation Guide](docs/installation.md) - Step-by-step setup instructions
505+
- [Configuration](docs/configuration.md) - Detailed configuration options
506+
- [Usage Guide](docs/usage.md) - Complete usage patterns and workflows
507+
- [Commands Reference](docs/commands.md) - All five commands with examples
508+
- [Best Practices](docs/best-practices.md) - Professional TDD patterns
509+
- [Troubleshooting](docs/troubleshooting.md) - Common issues and solutions
510+
511+
### Practical Examples
512+
513+
The [`examples/`](examples/) directory contains comprehensive usage examples:
514+
515+
- [**Basic Usage**](examples/basic-usage.php) - Complete five-command workflow with status tracking
516+
- [**Advanced Usage**](examples/advanced-usage.php) - Enterprise patterns, CI integration, and status analysis
517+
- [**Examples README**](examples/README.md) - Real-world usage patterns and organization strategies
518+
519+
**Examples demonstrate:**
520+
- βœ… Five-command TDD workflow from init to promote
521+
- πŸ“Š Status tracking integration and analysis
522+
- πŸ—οΈ Test organization strategies for complex projects
523+
- πŸš€ Automated promotion workflows
524+
- πŸ“ˆ Performance monitoring and audit trails
525+
- πŸ”§ CI/CD integration patterns
422526

423527
## πŸ”§ Requirements
424528

0 commit comments

Comments
Β (0)