Skip to content


Subversion checkout URL

You can clone with
Download ZIP


@depends doesn't work when @expectedException is used on dependend method #547

Sgoettschkes opened this Issue · 2 comments

2 participants


If I use @expectedException on a method and then make another method depending on it using @depends, the return statement never executes leaving the argument null. A simple example:

 * @test
 * @expectedException \MyException
public function testExpectedException() {
    throw new \MyException();

    return 42;

 * @test
 * @depends testExpectedException
public function testDepends($fourtyTwo) {
    $this->assertEquals(42, $fourtyTwo);

I understand that under normal circumstances, the return value doesn't get executed. But as it is possible to configure it that way, either this should work somehow or it should give an error on initialization that a test cannot depend on a test that expecteds an exception.


if you use @ ExpectedException means that the function should return an exception. To perform the test you described, create a function that returns a value.


Actually, that makes a lot of sense. I was thinking totally different, expecting phpunit to somehow "know" which function I expect to throw an exception and wrap this in a try/catch.

I'll leave this open for a maintainer to decide if there should be a phpunit error when a depends is assigned on a method which has a expectedException annotation. If not, this issue is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.