Skip to content
This repository was archived by the owner on Jun 15, 2021. It is now read-only.
This repository was archived by the owner on Jun 15, 2021. It is now read-only.

@expectedException vs setExpectedException() #1

@remenic

Description

@remenic

Hi,

I've been trying to run unit tests on our CI system, but the tests that have the @ExpectedException docblock appear to fail. I have found that using $this->setExpectedException('Exception') works as expected.

It would probably be good practice to use the setExpectedException() right before calling the code that triggers the exception, since some of these tests perform multiple asserts. In the case that an exception is thrown in one of the earlier asserts, phpunit will consider the test successful.

Cheers!

  • Richard

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions