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. 你可以通过代码提示功能看到可以使用的全部断言方法。

 

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