断言是测试中的语句,检查条件是否为真 — 验证实际结果是否与预期结果相匹配。它们是测试如何确定通过或失败的核心:如果断言失败,测试就失败。
断言的作用
text
An ASSERTION checks that something is as expected:
→ "assert that the actual value EQUALS the expected value"
→ if TRUE → the assertion passes; if FALSE → the assertion FAILS → the TEST FAILS
→ Assertions are how a test VERIFIES behavior (the "check" part of a test).
常见的断言类型
js
(result).();
(obj).({ : });
(value).();
(value).();
(value).();
(count).();
(price).();
(array).();
(array).();
(text).();
( ()).();
(value)..();
