Mock object framework (3)
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 5 Isolation (mock object) framework
有關return value的問題
大家對於被mock 的部份要如何傳回值應該會有興趣, 這裡讓我們看看Rhino Mock可以怎麼做
kojenchieh 發表在 痞客邦 留言(0) 人氣()
Mock object framework (2)
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 5 Isolation (mock object) framework
1. strict mock object
- 預期要呼叫的method和處理的參數要一模一樣, 否則測試就算失敗
kojenchieh 發表在 痞客邦 留言(0) 人氣()
Mock object framework (1)
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 5 Isolation (mock object) framework
由前一個章節可以知道, 若是要自己撰寫stub或是mock, 會很花時間. 若是受測程式的interface很複雜, method很多, parameter很多, 都會使難度變高.
所以若是有個mock object framework來幫助我們處理這些事情, 將會大大解省開發的代價. 在這裡作者要和我們推薦的是Rhino Mock, 你可以在http://ayende.com中下載它們
kojenchieh 發表在 痞客邦 留言(0) 人氣()
利用mock object來進行interaction testing
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 4 Interaction testing using mock objects
首先我們先對一個名詞先做個了解: Interaction testing:
- Interaction testing is testing how an object sends input to or receives input from other objects
kojenchieh 發表在 痞客邦 留言(0) 人氣()
利用Stub來打破關連性 (4)
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 3 Using stubs to break dependencies
最後一種方式, 作者是用factory method來處理.
老實說, 第一次看的時候, 覺得有點複雜. 不知道大家覺得如何.
kojenchieh 發表在 痞客邦 留言(1) 人氣()
利用Stub來打破關連性 (3)
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 3 Using stubs to break dependencies
接下來作者提出另一種作法, 使用factory paatern. 這樣做的好處是
(1) 你的受測程式便不用管FileExtension Manager是怎樣產生, 或是要用哪一個
kojenchieh 發表在 痞客邦 留言(0) 人氣()
利用Stub來打破關連性 (2)
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 3 Using stubs to break dependencies
之前用constructor的方法來傳入stub object, 這樣的作法有什麼問題嗎?
有經驗的人一定會想到, 若是有多個stub object, 或是可能之後要動態增加stub時, 這樣的作法不就要常常改constructor, 因此作者提出另外一個作法: 利用property來設定stub.
kojenchieh 發表在 痞客邦 留言(0) 人氣()
利用Stub來打破關連性 (1)
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 3 Using stubs to break dependencies
在撰寫測試程式時, 遇到最大的問題是, 受測程式和其他程式有關聯. 因為這樣的關連, 會導致你要進行單元測試的困難度.
例如下面這個程式, 若是你要測試時, 必需要和file system有互動.
kojenchieh 發表在 痞客邦 留言(0) 人氣()
Unit test and State-based testing
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 2 A first unit test
1. 簡單的單元測試範例
(1) 受測類別
kojenchieh 發表在 痞客邦 留言(0) 人氣()
單元測試的基本觀念
Source: The art of unit testing with examples in .NET, Roy Osherove
http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274/ref=sr_1_1?ie=UTF8&s=books&qid=1267086529&sr=1-1
Chapter 1 The basics of unit testing
1. Unit test的定義
為了讓大家有相同的認知, 作者定義了unit test是什麼.
kojenchieh 發表在 痞客邦 留言(2) 人氣()
Mock和Stub的比較
Martin Fowler 寫過一篇文章, 叫"Mocks aren’t stubs" (http://martinfowler.com/articles/mocksArentStubs.html). 討論Mock和 stub的不同
說真的一開始看了半天, 不是很懂他要講什麼, 後來在網路上看了半天, 終於比較有感覺了. 以下是我簡單的整理.
首先我們首先看個例子:
(1)定義一個 Mail Service的interface
public interface MailService {
kojenchieh 發表在 痞客邦 留言(1) 人氣()
TDD和Unit Test, Accpetance Test的比較
很多時候大家不清楚TDD和Unit test, accpetance test有時麼差別, 因此在撰寫測試時, 都把他們混在一起. 到時候再來說, TDD不work.
小弟整理了一下它們之間的差別, 有經驗的讀者歡迎補充一下
TDD v.s. Unit Test
1. Test first v.s. Test after

kojenchieh 發表在 痞客邦 留言(1) 人氣()
TDD 的簡介
http://www.agiledata.org/essays/tdd.html
TFD(Test first design) 的步驟
(1) 先快速加入一個測試, 基本上是足夠讓程式不能運作就可以
(2) 接下來執行你的測試, 已確定這個新增的測試會失敗
kojenchieh 發表在 痞客邦 留言(0) 人氣()
kojenchieh 發表在 痞客邦 留言(0) 人氣()
TDD應用狀況的調查 (下)
Test Driven Development (TDD) Survey: October 2008
http://www.ambysoft.com/surveys/tdd2008.html
Posted by Scott W. Ambler
Published in Ambysoft
kojenchieh 發表在 痞客邦 留言(0) 人氣()
TDD應用狀況的調查 (上)
Test Driven Development (TDD) Survey: October 2008
http://www.ambysoft.com/surveys/tdd2008.html
Posted by Scott W. Ambler
Published in Ambysoft
kojenchieh 發表在 痞客邦 留言(1) 人氣()
TDD 相關資料整理
這是我目前收集到TDD相關有用的資料, 應該可以看很久吧!! Enjoy them
Web Sites
1. xUnit Patterns.com
kojenchieh 發表在 痞客邦 留言(0) 人氣()
TDD和Unit Tests, Acceptance Tests的比較
TDD Tests are not Unit Tests
http://stephenwalther.com/blog/archive/2009/04/11/tdd-tests-are-not-unit-tests.aspx
April 11, 2009
Posted by Stephen Walther
kojenchieh 發表在 痞客邦 留言(4) 人氣()
常見的TDD Bad Smells
TDD Process Smells
http://agileinaflash.blogspot.com/2009/03/tdd-process-smells.html
Tuesday, March 31, 2009
Posted by Jeff Langr
kojenchieh 發表在 痞客邦 留言(0) 人氣()
如何讓你實踐TDD能成功的方法
Making TDD Stick: Problems and Solutions for Adopters
http://www.infoq.com/articles/levison-TDD-adoption-strategy
Jan 05, 2009
Posted by Mark Levison
kojenchieh 發表在 痞客邦 留言(0) 人氣()