PHPackages                             jchook/phpunit-assert-throws - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jchook/phpunit-assert-throws

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jchook/phpunit-assert-throws
============================

Exception assertions for PHPUnit

v1.0.3(7y ago)111.7M↑26.7%316MITPHP

Since Apr 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jchook/phpunit-assert-throws)[ Packagist](https://packagist.org/packages/jchook/phpunit-assert-throws)[ RSS](/packages/jchook-phpunit-assert-throws/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (16)

PHPUnit `assertThrows()`
========================

[](#phpunit-assertthrows)

Industry standard, lambda-based exception testing assertions for PHPUnit.

Installation
------------

[](#installation)

Easily install it with composer:

```
composer require --dev jchook/phpunit-assert-throws
```

Or, alternatively [copy the tiny gist](https://raw.githubusercontent.com/jchook/phpunit-assert-throws/master/src/AssertThrows.php) and add it to you project. No attribution is requried. True artists steal.

Rationale
---------

[](#rationale)

To enable lambda-based exception testing syntax to [PHPUnit](https://docs.phpunit.de/en/10.4/writing-tests-for-phpunit.html#expecting-exceptions).

- Throw multiple errors per test
- Examine and test errors after they are caught
- Copy-paste usage examples
- Use standard `assert*` syntax
- Test more than just `message`, `code`, and `class`
- Write simple happy-path tests with `assertNotThrows`

Example
-------

[](#example)

Just to illustrate the spirit behind the syntax:

```

```

Notes
-----

[](#notes)

Yes, `assertNotThrows()` feels grammatically… odd. However, it conforms with the PHPUnit naming conventions, such as [`assertNotContains()`](https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertContains). Additionally, the PHPUnit team suggests [we may not need this inverse assertion](https://github.com/sebastianbergmann/phpunit-documentation/issues/171).

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 95.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~124 days

Total

4

Last Release

2592d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/047da3410a118e06b8f9e170318c1c1197a6dbd5ceebe1a43ee91251d49c7632?d=identicon)[jchook](/maintainers/jchook)

---

Top Contributors

[![jchook](https://avatars.githubusercontent.com/u/193530?v=4)](https://github.com/jchook "jchook (21 commits)")[![jean-beguin](https://avatars.githubusercontent.com/u/39402471?v=4)](https://github.com/jean-beguin "jean-beguin (1 commits)")

### Embed Badge

![Health badge](/badges/jchook-phpunit-assert-throws/health.svg)

```
[![Health](https://phpackages.com/badges/jchook-phpunit-assert-throws/health.svg)](https://phpackages.com/packages/jchook-phpunit-assert-throws)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[jasonmccreary/laravel-test-assertions

A set of helpful assertions when testing Laravel applications.

3513.9M32](/packages/jasonmccreary-laravel-test-assertions)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[robiningelbrecht/phpunit-pretty-print

Prettify PHPUnit output

76460.0k15](/packages/robiningelbrecht-phpunit-pretty-print)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
