Test Fixture


在進行Test driven developemnt時, 常常會提到一個名詞: test fixture. 很多人對這個term不是很了解. 因此我整理了一些資料, 希望有助於大家的了解

1. 定義:
A test fixture is all the things we need to have in place in order to run a test and expect a particular outcome.
A test fixture is a fixed state of a set of objects used as a baseline for running tests.

也就是當在進行測試時, 需要用到的一些資料來輔助測試的進行. 例如受測物件的某個特定狀態(state), 資料庫中的資料(如connection string), 或是某些檔案. 這些資料我們稱之為test fixture. 我們會利用這些test fixture, 來進行我們想要的測試.


2. 如何產生test fixture
- 你可以在每個測試函式中, 產生出你所要的資料. 但是這容易產生duplication的問題
- 在xUnit中, 我們通常在setUp()中建立我們想要的test fixture. 然後在tearDown()中把它們清掉.

3. 參考資料
1.
http://en.wikipedia.org/wiki/Test_fixture
2. http://xunitpatterns.com/test%20fixture%20-%20xUnit.html
3. http://sqa.fyicenter.com/FAQ/JUnit/What_Is_a_JUnit_Test_Fixture_.html

arrow
arrow
    全站熱搜

    kojenchieh 發表在 痞客邦 留言(0) 人氣()