shipping.pyExecutable specification
python
from niltest import case, docs, scenario
@scenario("配送料")
@docs(case("プレミアム会員", given={"premium": True}, returns=0))
def shipping_fee(premium: bool) -> int:
return 0 if premium else 500ONE SOURCE OF TRUTH
一度書いたケースを、開発全体で使う。
説明のためのサンプルと、テストの入力と、モックの戻り値を別々に保守する必要はありません。
START SMALL
まずひとつの関数から。
設定ファイルも実行時依存も不要です。既存プロジェクトへ段階的に追加できます。