Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Which PHPUnit are you using? I am using PHPUnit 4.7.5, and there assertException is not defined. I also cannot find it in the PHPUnit manual. Commented Jul 22, 2015 at 8:34
  • 2
    The asertException method is not part of original PHPUnit. You must inherit the PHPUnit_Framework_TestCase class and add method linked in post above manually. Your test cases will then inherit this inherited class.
    – hejdav
    Commented Jul 27, 2015 at 11:40
  • This is great. I was asserting my expectation of two exceptions, and phpunit's output only showed one assertion. Commented Feb 18, 2022 at 20:17