Assertionlar, bir testte bir koşulun doğru olup olmadığını kontrol eden ifadelerdir — gerçek sonucun beklenen sonuçla eşleşip eşleşmediğini doğrular. Testlerin geçip geçmemeyi belirleyen temel mekanizmadır: bir assertion başarısız olursa, test başarısız olur.
Assertionlar ne yapar
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).
Yaygın assertion türleri
(result).();
(obj).({ : });
(value).();
(value).();
(value).();
(count).();
(price).();
(array).();
(array).();
(text).();
( ()).();
(value)..();
