k2gl/phpunit-fluent-assertions
A PHPUnit extension that adds fluent, chainable assertions to your tests, making expectations more readable and expressive while reducing verbose assertion code and keeping familiar PHPUnit workflows.
doesNotThrow() and an inspect callback for throws() — directly reduces boilerplate when asserting on exception boundaries, which is one of the most common and most verbose assertion patterns in Laravel service/action tests (jobs, HTTP clients, transactions).try/catch + $this->fail() blocks or expectException() (which can't inspect exception state). The new throws() inspect callback lets a test assert both that something threw and what it carried (message, error code, validation bag) in one fluent statement — a concrete improvement in test clarity for payment, auth, and integration code.Adopt when:
throws() inspect callback and doesNotThrow() give a cleaner alternative to expectException() + manual try/catch.Look elsewhere / skip when:
For executives: this is a small, free, test-only library that makes our automated tests shorter and clearer. The latest release targets the hardest part of testing — error and exception paths — which is usually where production bugs hide. Cost is a one-line dev dependency; there is no production runtime impact and no licensing cost. The main risk is that it is maintained by a single volunteer, so we pin the version and can remove it in an afternoon if needed.
For engineering leadership: adopt in new tests first. 12.12.0 adds doesNotThrow() and an inspect callback on throws(), letting us replace try/catch-and-fail blocks with a single chainable assertion that can also inspect exception state. Low blast radius, incremental adoption, improves readability in code review, and reduces bespoke assertion helpers we maintain ourselves.
For the engineering team: treat it as tooling, not architecture. Pin the major, upgrade it alongside PHPUnit, and prefer it for exception-boundary assertions. If the maintainer stalls, fall back to the existing expectException() patterns — nothing in the codebase becomes permanently dependent on it.
How can I help you explore Laravel packages today?