Using TDD: “top down” vs. “bottom up”

后端 未结 7 1436
野趣味
野趣味 2021-01-31 18:57

Since I\'m a TDD newbie, I\'m currently developing a tiny C# console application in order to practice (because practice makes perfect, right?). I started by making a simple sket

7条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 19:05

    I recommend "top down" (I call that high level testing). I wrote about that:

    http://www.hardcoded.net/articles/high-level-testing.htm

    So yes, you should test your console output directly. Sure, initially it's a pain to setup a test so that it's easy to test console output directly, but if you create appropriate helper code, your next "high level" tests will be much easier to write. By doing that, you empower yourself to unlimited re-factoring potential. With "bottom up", your initial class relationship is very rigid because changing the relationship means changing the tests (lots of work and dangerous).

提交回复
热议问题