字號: 小 中 大 |
推薦給好友
上一篇 |
下一篇
Mock Objects:缺點和用例
發布: 2008-6-13 18:23 |
作者: 不詳 |
來源:
領測軟件測試網編輯整理 |
查看: 163次 | 進入領測軟件測試網論壇討論
領測軟件測試網
jLL6M:a7~
d
Z
H
/**
* Encapsulates the common pattern followed when using EasyMock.
* <ol>
* <li>Set up expectations on the mock objects</li>
* <li>Set the state of the mock controls to "replay"</li>
* <li>Execute the code to test</li>
* <li>Verify that the expectations were met</li>
* </ol>
* Steps 2 and 4 are considered invariant behavior while steps 1 and 3 should be implemented by subclasses of this template.
*/
public final void run() {
setUp();
expectations();
for (Object mock : mocks) replay(mock);
codeToTest();
for (Object mock : mocks) verify(mock);
}
/** Sets the expectations on the mock objects. */
protected abstract void expectations();
/** Executes the code that is under test. */
protected abstract void codeToTest();
/** Sets up the test fixture if necessary. */
protected void setUp() {}
}
軟件測試技術網)YSFu0R
老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月