unit testing - TDD should I create an empty class needed for a test case? -


i'm new tdd , keen start using it, keep hitting bump whenever test case i'm working on requires class doesn't yet exist (either input or output).

the problem don't know whether create class without functionality (is considered untested code or not ?), or stop working on test (while it's green), , start writing test new non-existing class.

the second approach seems recursive, , might cause me lose train of thought, while first creates new class there's no test.

is there third approach didn't think of, preferable ?

you can go both ways. sometimes, creating new auxiliary class , leave empty shell time being approach.

however, main benefit of tdd feedback code, if happens lot, should stop , consider tells design of api.

still, there's nothing inherently wrong this, because depends on overall approach. if you're doing outside-in tdd tend happen lot, because start @ abstract level , work way down (and lover-level classes don't yet exist).

on other hand, if bottom-up tdd, shouldn't happen often, because start building blocks, , compose higher-level classes building blocks.

in case, 'recursive' approach example of situation using git shines, because every time experience need write test before 1 you're writing, can go

git stash 

and write new test. when you're done new test, can go

git stash pop 

to return original test. can recursively, helps keep track of thoughts.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -