â /test
Write tests for code using test-driven development principles
Command Usage
Invoke this command in Claude Code:
/testdescription: Write tests for code using test-driven development principles disable-model-invocation: false
Write tests for the specified code or feature using test-driven development (TDD) methodology.
Process
Use the test-driven-development skill from bushido to:
- Understand the requirement: Clarify what needs to be tested
- Write failing test first: Create a test that fails because the feature doesn't exist yet
- Run the test: Verify it fails for the right reason
- Implement minimal code: Write just enough code to make the test pass
- Run test again: Verify it now passes
- Refactor: Improve code quality while keeping tests green
- Repeat: Continue for each requirement
Key Principles
- Red â Green â Refactor: The core TDD cycle
- Test behavior, not implementation: Focus on what the code does, not how
- One test per requirement: Keep tests focused and clear
- Verify test fails first: Ensures the test is actually testing something
Examples
When the user says:
- "Write tests for the authentication module"
- "Add tests for the calculateTotal function"
- "I need test coverage for the user registration flow"
- "Test the edge cases for date parsing"
Notes
- Use TodoWrite to track progress through TDD cycles
- Run full test suite before considering work complete
- Tests should be clear enough to serve as documentation
- Follow existing test patterns in the codebase