Robin Andrews
Robin Andrews

Reputation: 3804

TDD basics - do I add or replace tests?

I'm completely new to TDD and am working my way through this article.

It's all very clear except for a basic thing that probably seems too obvious to mention:

Having run the first test (module exists), what do I do with my code before running the next one? Do I keep it so the next test includes results from the first one? Do I delete the original code? Or do I comment it out and only leave the current test uncommented?

Put another way, does my spec file end up as long list of tests which are run every time, or should it just contain the current test?

Upvotes: 0

Views: 33

Answers (1)

Nkosi
Nkosi

Reputation: 247423

Quoting the same article linked to in the question.

Since I don’t have a failing test though, I won’t write any module code. The rule is: No module code until there’s a failing test. So what do I do? I write another test—which means thinking again.

Spec will end up with list of tests which are run every time to check for regression errors for every additional feature. If adding a new feature breaks something that was added before then the previous tests will indicate by failing the test.

Upvotes: 2

Related Questions