shipping.pyExecutable specification
python
from niltest import case, docs, scenario
@scenario("Shipping fee")
@docs(case("Premium member", given={"premium": True}, returns=0))
def shipping_fee(premium: bool) -> int:
return 0 if premium else 500ONE SOURCE OF TRUTH
Use one case across your development workflow.
Stop maintaining separate examples for documentation, test inputs, and mock return values.
Reviewable behavior beside the implementation
Concrete inputs and outcomes make intent visible without forcing readers to infer it from implementation details.
Explore the conceptsMove forward without external services
Reuse the same cases as fixed development mocks.
Explore mockingCheck the implementation immediately
Run declared cases against the real function.
Explore testingKeep development support out of the production path
The declaration API returns your original function in production.
Explore production modeSTART SMALL
Begin with one function.
No configuration file and no runtime dependencies. Adopt niltest gradually in an existing project.