by sickn33
在没有明确测试定义的情况下开始 TDD 会导致覆盖不完整。此技能在实现开始前创建全面的失败测试来定义预期行为。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 tdd-workflows-tdd-red 技能" 开始使用
=== tdd-workflows-tdd-red 技能 === 作者: sickn33 描述: 在没有明确测试定义的情况下开始 TDD 会导致覆盖不完整。此技能在实现开始前创建全面的失败测试来定义预期行为。 使用方法: 1. 调用技能: "使用 tdd-workflows-tdd-red 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 tdd-workflows-tdd-red 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
coding
safe
Write comprehensive failing tests following TDD red phase principles.
[Extended thinking: Generates failing tests that properly define expected behavior using test-automator agent.]
Generate failing tests using Task tool with subagent_type="unit-testing::test-automator".
"Generate comprehensive FAILING tests for: $ARGUMENTS
Test Structure
Behavior Coverage
Failure Verification
Test Categories
JavaScript/TypeScript (Jest/Vitest)
vi.fn() or jest.fn()@testing-library for React componentsfast-checkPython (pytest)
Go
t.Parallel() for parallel executiontestify/assert for cleaner assertionsRuby (RSpec)
let for lazy loading, let! for eagerAfter generation:
// auth.service.test.ts
describe('AuthService', () => {
let authService: AuthService;
let mockUserRepo: jest.Mocked<UserRepository>;
beforeEach(() => {
mockUserRepo = { findByEmail: jest.fn() } as any;
authService = new AuthService(mockUserRepo);
});
it('should_return_token_when_valid_credentials', async () => {
const user = { id: '1', email: 'test@example.com', passwordHash: 'hashed' };
mockUserRepo.findByEmail.mockResolvedValue(user);
const result = await authService.authenticate('test@example.com', 'pass');
expect(result.success).toBe(true);
expect(result.token).toBeDefined();
});
it('should_fail_when_user_not_found', async () => {
mockUserRepo.findByEmail.mockResolvedValue(null);
const result = await authService.authenticate('none@example.com', 'pass');
expect(result.success).toBe(false);
expect(result.error).toBe('INVALID_CREDENTIALS');
});
});
Test requirements: $ARGUMENTS
View Count
0
Download Count
0
Favorite Count
0
Quality Score
71