Demo: refactoring a long method with an assistant under green tests
On This Lesson 3 topics
The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.
In this lesson
refactor CheckoutService with an assistant while keeping tests green. Prepares JNR-055-LAB1.
Draft outline details
Step by step
- Run the tests: green. Open the log file for prompts.
- Write a context-rich prompt to extract the discount block; read the proposed diff.
- Accept the small change; run the tests; log what you accepted.
- Planned mistake: accept a large suggestion that also changes rounding; a test fails. Fix: reject it, log the reason, and ask again for only the extraction.
- Ask the assistant for missing tests; check each assertion; delete one that asserts nothing useful.
- Commit with a note that AI helped, if the team requires it.
Check your understanding
What do you do with a big suggestion that breaks a test?
Show answer
Reject it and ask again for a smaller step.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.