Loading...
Loading...
Compare original and translation side by side
WRONG(横向):
RED: test1, test2, test3, test4, test5
GREEN: impl1, impl2, impl3, impl4, impl5
RIGHT(竖向):
RED→GREEN: test1→impl1
RED→GREEN: test2→impl2
RED→GREEN: test3→impl3
...WRONG(Horizontal):
RED: test1, test2, test3, test4, test5
GREEN: impl1, impl2, impl3, impl4, impl5
RIGHT(Vertical):
RED→GREEN: test1→impl1
RED→GREEN: test2→impl2
RED→GREEN: test3→impl3
...公共接口应当长什么样?哪些行为最重要、最需要先测?What should the public interface look like? Which behaviors are most critical and need to be tested first?RED: 为第一个行为写测试 → 测试失败
GREEN: 写最小代码让测试通过 → 测试通过RED: Write test for the first behavior → test fails
GREEN: Write minimal code to pass the test → test passesRED: 写下一个测试 → 失败
GREEN: 最小实现让它通过 → 通过RED: Write next test → fails
GREEN: Minimal implementation to pass it → passes[ ] 测试描述的是行为,而不是实现
[ ] 测试只使用公共接口
[ ] 测试在内部重构后仍能存活
[ ] 针对该测试的代码足够最小
[ ] 没有加入“为了以后而猜”的功能[ ] Tests describe behavior, not implementation
[ ] Tests only use public interfaces
[ ] Tests survive internal refactoring
[ ] Code for this test is minimal enough
[ ] No "guessing for the future" features added