ユニットテストは、コードの個々のユニット(関数、メソッド、クラス)を分離して検証し、各小さなピースが単独で正しく機能しているかを確認します。ユニットテストは高速で焦点を絞ったもので、優れたテスト戦略の基礎を形成します。
ユニットテストとは
A UNIT test verifies the smallest testable piece (a function/method) in ISOLATION:
→ test ONE thing; give inputs, check the output/behavior
→ ISOLATED from dependencies (database, network, other units) — mock/stub those
→ FAST (no real I/O), focused, deterministic
例
() { a + b; }
(, {
((, )).();
((-, )).();
});
(, {
cart = ();
cart.({ : });
cart.({ : });
(cart.).();
});
