xiaohongshu
xiaohongshu
tdd
Test-Driven Development facilitation using the red-green-refactor cycle. Guides users through writing tests first, implementing minimal code to pass, and refactoring for quality. Use when users want to practice TDD, need help writing tests before code, are developing new features test-first, or w...
Full skill instructions
Guide users through disciplined test-first development using the red-green-refactor cycle.
RED → GREEN → REFACTOR → REPEAT
Critical rules to follow:
Activate for requests involving:
Arrange - Set up test data and environment Act - Execute the code under test Assert - Verify the results
def test_add_two_numbers():
calculator = Calculator() # Arrange
result = calculator.add(2, 3) # Act
assert result == 5 # Assert
Given - Initial context/preconditions When - Action/event occurs Then - Expected outcome
test_add_returns_sum_of_two_positive_numbersSee references/test-design-patterns.md for comprehensive guidance.
See references/python-tdd.md for:
See references/elisp-tdd.md for:
See references/general-tdd.md for:
What: Test individual functions/methods in isolation
When:
Example: test_calculate_discount(price, percentage)
What: Test multiple components working together
When:
Example: test_user_service_saves_to_database()
What: Test complete user workflows
When:
Example: test_user_can_register_and_login()
Test Pyramid:
/\ ← Few E2E tests (slow, brittle)
/ \
/ IT \ ← Some Integration tests
/______\
/ Unit \ ← Many Unit tests (fast, focused)
/__________\
Goal: Implement factorial function
Iteration 1 - Base case:
test_factorial_of_zero_is_one() → ❌ factorial not defineddef factorial(n): return 1 → ✅ PassesIteration 2 - Positive numbers:
test_factorial_of_five() expects 120 → ❌ Got 1Iteration 3 - Error handling:
test_factorial_negative_raises_error() → ❌ No error raisedDone! Function is complete, fully tested, documented. Three test-driven iterations.
Mock - Programmed with expectations, verifies interactions Stub - Provides canned responses, doesn't verify Fake - Working implementation, simpler than real Spy - Records calls, allows verification after
See references/test-design-patterns.md for detailed mocking strategies.
Don't:
❌ Write implementation before test - Defeats TDD purpose
❌ Write multiple tests before making them pass - Stay in rhythm (one test, make it pass, next test)
❌ Refactor with red tests - Only refactor when green
❌ Test implementation details - Test behavior, not internals
❌ Skip refactor step - Technical debt accumulates
❌ Write tests that are hard to understand - Tests are documentation
❌ Create dependencies between tests - Tests must be independent
❌ Mock everything - Use real objects when practical
❌ Fake it with hardcoded values forever - "Fake it till you make it" is temporary
❌ Write slow tests - Slow test suite won't be run frequently
Good test names are descriptive and specific:
test_<function>_<scenario>_<expected_result>test_add_two_positive_numbers_returns_sum()
test_add_with_negative_number_returns_correct_result()
test_add_with_zero_returns_other_number()
should_<expected_behavior>_when_<condition>should_return_empty_list_when_no_items_match()
should_raise_error_when_input_is_null()
should_calculate_discount_when_user_is_premium()
<behavior>_<state>_<expected>(ert-deftest save-buffer-modified-saves-to-file ())
(ert-deftest load-file-missing-raises-error ())
Test name should:
Python:
project/
├── src/
│ └── calculator.py
└── tests/
├── __init__.py
├── test_calculator.py
└── conftest.py # pytest fixtures
Elisp:
package/
├── my-package.el
└── test/
└── test-my-package.el
test_*.py, *_test.py, test-*.eltest_ or ert-deftestTest* (if using classes)See language-specific references for detailed organization patterns.
If test is testing implementation detail:
If test is testing behavior:
If too many tests break:
See references/refactoring-with-tests.md for detailed guidance.
Coverage measures which code is executed by tests, not whether tests are good.
Use scripts/coverage_analyzer.py to identify coverage gaps.
Additional resources in this skill:
TDD Cycle:
Test Structure:
Test Principles:
Refactoring Rules:
Remember: TDD is a discipline. The value comes from following the cycle strictly. Test first. See it fail. Make it pass. Refactor. Repeat. The rhythm creates quality code.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience