[Study Note] TDD and Unit Test 20100401

之前的一篇 study note 长到了让人无法阅读的地步,所以这次打算分开来记录,不太喜欢那种1、2、3……式的罗列,所以就采用日期来作为分篇的标记。

主要是从 Jeremy D.Miller 的 blog 上看到了一些文章开始,部分文章已经有年头了,不过对于我来说还是新的东西。

最近开始的 study note 系列,其实就是自己的一些学习笔记,抄写一些自认为有价值的句子和代码,除了一些读后感,这里基本上没有原创的内容,放在这里主要也是为了将来能够便于搜索。以前有些写纸质的笔记,但是很少有机会再去翻看,另外也不便于查找。

 

[Qualities of a Good Unit Test]

Unit Tests Should Be Atomic

“Write a little test, write a little code”

Another feedback loop for your unit testing quality is the amount of time you spend with the debugger.

Order Independent and Isolated

Intention Revealing

Easy to Setup

decouple unit test from external dependencies like database and web services by using mocks or stubs.

Runs Fast.

segregate connected tests into a seperate assembly.

对于我现在来说可能单元测试的独立性是最迫切需要解决的,我的单元测试现在还是要依赖于数据库或者是其他的外部资源,虽然也试用过 Rhino Mock,但确实还不能发挥其作用。

 

[Design and Testability]

这个更像是一篇索引式的文章,而我恰恰打算按图索骥。

good, fundamental design is being able to do one thing at a time.

Testability means being able to easily create rapid, effective, and focused feedback cycles against your code with automated tests.

good design is far more beneficial and important than the practice of unit test

这样看来又得去补课了,线索就是 Miller 在 MSDN Magzine 上的 Patterns in Practice 系列文章

posted on 2010-04-01 23:54  zhaorui  阅读(154)  评论(0编辑  收藏  举报

导航