agentleFS
MicrosoftKnown publishermicrosoft/data-formulator/.cursor/rules/test-driven-workflow.mdc

data-formulator / rules

Cursor rule18k starsChanged 7 months agoMITView on GitHub

测试优先开发与测试保护规则。确保新功能/Bug 修复必须有测试覆盖,测试失败时先诊断后修改。

Trending

Steady talk.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 1 mentionAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 2 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/data-formulator repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about microsoft/data-formulator

The biggest 5 of 31 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 31

Talked about on Bluesky, GitHub and Hacker News (31 times).

On Bluesky · 22

17 more on Bluesky

On GitHub · 7

2 more on GitHub

The file

Files
test-driven-workflow.mdc
---
description: 测试优先开发与测试保护规则。确保新功能/Bug 修复必须有测试覆盖,测试失败时先诊断后修改。
globs: 
alwaysApply: true
---

# Test-Driven Workflow

## 1. 测试优先:新功能 / Bug 修复必须有测试

开发新功能或修复 Bug 时,**必须同步编写测试**,不能只提交业务代码:

- **新功能** → 先写测试(或至少同步写),描述期望行为,再实现代码使测试通过
- **Bug 修复** → 先写复现测试,确认测试失败,再修复代码使测试通过
- **重构** → 确保重构前已有测试覆盖,重构后测试仍然全部通过

完成实现后,主动运行相关测试验证:
- 后端:`python -m pytest tests/backend/ -q`
- 前端:`yarn test`

## 2. 测试保护:不要轻易修改测试代码

测试失败时,**禁止直接修改测试代码来让测试通过**。必须执行以下流程:

1. **复现并定位**:运行失败的测试,确认失败现象
2. **诊断分类**:
   - A:测试本身有问题(断言错误、setup 不正确)
   - B:业务实现有 Bug
   - C:需求/规格变更导致测试过时
3. **给出方案**:至少提供两个可选方案(改测试 / 改实现 / 补规格),说明各自影响和风险
4. **等待确认**:由用户决定采用哪个方案,再执行修改

**绝对禁止**:
- 测试一红就直接改测试代码
- 删除或跳过(`@pytest.mark.skip`)失败的测试来"解决"问题
- 修改测试的断言值来匹配错误的实现

## 3. 精准修改:不动无关测试

与 Karpathy 编码准则的"精准修改"一致:

- 不"顺手改进"与当前任务无关的测试代码
- 不重构正在通过的测试
- 不改变已有测试的断言逻辑,除非被明确要求

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.