Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

step-04-session-05.md 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. ---
  2. name: 'step-04-session-05'
  3. description: 'Session 5: ATDD & Automate - TDD red-green approach, generate tests (60 min)'
  4. progressFile: '{test_artifacts}/teaching-progress/{user_name}-tea-progress.yaml'
  5. sessionNotesTemplate: '../templates/session-notes-template.md'
  6. sessionNotesFile: '{test_artifacts}/tea-academy/{user_name}/session-05-notes.md'
  7. nextStepFile: '{skill-root}/steps-c/step-03-session-menu.md'
  8. advancedElicitationTask: '{project-root}/_bmad/core/workflows/advanced-elicitation/workflow.xml'
  9. partyModeWorkflow: '{project-root}/_bmad/core/workflows/party-mode/workflow.md'
  10. ---
  11. # Step 4: Session 5 - ATDD & Automate
  12. ## STEP GOAL:
  13. To teach ATDD (red-green TDD) and Automate workflows for test generation in a 60-minute session.
  14. ## MANDATORY EXECUTION RULES (READ FIRST):
  15. ### Universal Rules:
  16. - 🛑 NEVER generate content without user input
  17. - 📖 CRITICAL: Read complete step file before action
  18. - ✅ YOU MUST ALWAYS SPEAK OUTPUT In {communication_language}
  19. ### Role Reinforcement:
  20. - ✅ Master Test Architect and Teaching Guide
  21. - ✅ Collaborative learning
  22. ### Step-Specific Rules:
  23. - 🎯 Focus on Session 5 (ATDD & Automate)
  24. - 💬 Teach TDD approach
  25. ## EXECUTION PROTOCOLS:
  26. - 🎯 Load docs just-in-time
  27. - 💾 Generate notes
  28. - 📖 Update progress
  29. - ⏭️ Return to hub
  30. ## MANDATORY SEQUENCE
  31. ### 1. Welcome
  32. "🧪 **Session 5: ATDD & Automate** (60 minutes)
  33. **Objective:** Generate tests with TDD red-green approach
  34. **What you'll learn:**
  35. - ATDD workflow (failing tests first)
  36. - Automate workflow (expand coverage)
  37. - Component TDD
  38. - API testing patterns
  39. Let's generate some tests!"
  40. ### 2. Update Progress (Started)
  41. Load {progressFile} and update session-05-atdd-automate:
  42. - Set `status: 'in-progress'`
  43. - Set `started_date: {current_date}` if not already set
  44. Save the updated progress file.
  45. ### 3. Teaching: ATDD Workflow
  46. "### 🔴 ATDD: Acceptance-Driven Test Development
  47. **TDD Red Phase:** Write failing tests FIRST
  48. **ATDD Workflow:**
  49. 1. **Preflight:** Check prerequisites
  50. 2. **Test Strategy:** Define what to test
  51. 3. **Generate FAILING Tests:** Red phase (tests fail because code doesn't exist yet)
  52. 4. **Implement Code:** Green phase (make tests pass)
  53. **Why Failing Tests First:**
  54. - Validates tests actually test something
  55. - Prevents false positives
  56. - Drives implementation (tests define behavior)
  57. {Role-adapted example}
  58. **Documentation:** <https://bmad-code-org.github.io/bmad-method-test-architecture-enterprise/how-to/workflows/run-atdd/>"
  59. ### 4. Teaching: Automate Workflow
  60. "### 🤖 Automate: Expand Test Coverage
  61. **Purpose:** Generate tests for existing features
  62. **Automate Workflow:**
  63. 1. **Identify Targets:** What needs testing
  64. 2. **Generate Tests:** API and/or E2E tests
  65. 3. **Review & Run:** Tests should pass (code already exists)
  66. **Difference from ATDD:**
  67. - ATDD: Tests first, then code (red → green)
  68. - Automate: Code first, then tests (coverage expansion)
  69. {Role-adapted example}
  70. **Documentation:** <https://bmad-code-org.github.io/bmad-method-test-architecture-enterprise/how-to/workflows/run-automate/>"
  71. ### 5. Teaching: Component TDD
  72. "### 🔄 Component TDD Red-Green Loop
  73. **Pattern:**
  74. 1. **Red:** Write failing test
  75. 2. **Green:** Minimal code to pass
  76. 3. **Refactor:** Improve code, tests stay green
  77. 4. **Repeat:** Next requirement
  78. **Example:**
  79. ```typescript
  80. // RED: Test fails (function doesn't exist)
  81. test('calculates total price', () => {
  82. expect(calculateTotal([10, 20])).toBe(30);
  83. });
  84. // GREEN: Minimal implementation
  85. function calculateTotal(prices) {
  86. return prices.reduce((a, b) => a + b, 0);
  87. }
  88. // REFACTOR: Add validation, tests still green
  89. ```
  90. {Role-adapted example}
  91. **Knowledge Fragment:** component-tdd.md"
  92. ### 6. Teaching: API Testing Patterns
  93. "### 🌐 API Testing Patterns
  94. **Pure API Testing (no browser):**
  95. - Fast execution
  96. - Test business logic
  97. - Validate responses
  98. - Schema validation
  99. **Pattern:**
  100. ```typescript
  101. test('GET /users returns user list', async ({ request }) => {
  102. const response = await request.get('/api/users');
  103. expect(response.ok()).toBeTruthy();
  104. const users = await response.json();
  105. expect(users).toHaveLength(10);
  106. });
  107. ```
  108. {Role-adapted example}
  109. **Knowledge Fragment:** api-testing-patterns.md, api-request.md"
  110. ### 7. Quiz (3 questions)
  111. **Q1:** "What is the 'red' phase in TDD?
  112. A) Tests fail (code doesn't exist yet)
  113. B) Tests pass
  114. C) Code is refactored
  115. D) Tests are deleted"
  116. Correct: A
  117. **Q2:** "What's the difference between ATDD and Automate workflows?
  118. A) ATDD generates E2E, Automate generates API tests
  119. B) ATDD writes tests first (red phase), Automate tests existing code
  120. C) ATDD is faster than Automate
  121. D) They're the same workflow"
  122. Correct: B
  123. **Q3:** "Why use pure API tests without a browser?
  124. A) They look prettier
  125. B) They're easier to debug
  126. C) They're faster and test business logic directly
  127. D) They're required by TEA"
  128. Correct: C
  129. Calculate score, handle <70% retry.
  130. ### 8. Generate Session Notes
  131. Create {sessionNotesFile} with Session 5 content:
  132. - ATDD workflow (red-green TDD)
  133. - Automate workflow (coverage expansion)
  134. - Component TDD
  135. - API testing patterns
  136. - Docs: ATDD, Automate
  137. - Fragments: component-tdd.md, api-testing-patterns.md, api-request.md
  138. - Quiz results
  139. ### 9. Update Progress (Completed)
  140. Update session-05-atdd-automate: completed, score, notes.
  141. Increment sessions_completed, update percentage.
  142. Append 'step-04-session-05' to stepsCompleted.
  143. Set next_recommended: 'session-06-quality-trace'.
  144. ### 10. Complete Message
  145. "🎉 **Session 5 Complete!** Score: {score}/100
  146. You can now generate tests with ATDD and Automate!
  147. Progress: {completion_percentage}%"
  148. ### 11. Menu
  149. [A] Advanced Elicitation [P] Party Mode [C] Continue to Session Menu
  150. Return to {nextStepFile}.
  151. ---
  152. ## 🚨 SUCCESS METRICS
  153. ✅ ATDD and Automate taught, TDD explained, quiz passed, notes generated, progress updated, returned to hub.