0

I'd like to have PHPUnit fail when it encounters any PHP error, warning, or exception.

I'm seeing examples of the inverse, where

/**
 * @expectedException PHPUnit_Framework_Error_Warning
 */

is used when an error is expected. But instead, I'd like to exercise various code paths and guarantee that no errors, warnings, or exceptions were thrown.

1
  • 1
    For me, the question is not precise enough to answer but it feels like you're abusing PHPunit for something which doesn't sound like proper unit testing. Again, I may be wrong since I don't get enough information from your question. Maybe you could post some example (pseudo)code of what you would like to do. Commented Dec 16, 2011 at 7:37

1 Answer 1

2

Any test that throws an uncaught exception or raises a warning or error is automatically marked with E (for error) by PHPUnit without your intervention. You only need to take measures like @expectedException when you want to count such errors as correct behavior.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.