Flash Builder 4 Beta和FlexUnit下的測試驅動開發---斷言方法

Flash Builder 4 Beta和FlexUnit下的測試驅動開發---斷言方法

 

Assertion method

Meanings

assertEquals

Asserts that two values are equal.

assertContained

Asserts that the first string is contained in the second one.

assertNotContained

Asserts that the first string is not contained in the second one.

assertFalse

Asserts that a condition is false.

assertTrue

Asserts that a condition is true.

assertMatch

Asserts that a string matches a regular expression (regexp).

assertNoMatch

Asserts that a string doesn't match a regexp.

assertNull

Asserts that an object is null.

assertNotNull

Asserts that an object is not null.

assertNotUndefined

Asserts that an object is defined.

assertUndefined

Asserts that an object is undefined.

assertStrictlyEquals

Asserts that two objects are strictly identical.

assertObjectEquals

Asserts that two objects are equal.

轉載:http://www.adobe.com/cn/devnet/flex/articles/flashbuilder4_tdd_04.html

 

斷言方法要求三個參數:一個包括字符串信息,另兩個參數參與比較。字符串參數包含了測試失敗時的描述信息。例如:

assertEquals("Error testing the application state", state, 1);

如果不傳入該消息參數,FlexUnit將使用缺省信息。

在編輯器中鍵入Assert. 你可以通過代碼提示功能看到可以使用的全部斷言方法。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章