Skip to content

Commit facb188

Browse files
SlamdunkDavertMik
authored andcommitted
Verbose fail message when no Exception caught (#4933)
1 parent 139eb88 commit facb188

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Codeception/Module/Asserts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ public function expectException($exception, $callback)
465465
));
466466
}
467467
$this->assertTrue(true); // increment assertion counter
468-
return;
468+
return;
469469
}
470-
$this->fail("Expected exception to be thrown, but nothing was caught");
470+
$this->fail("Expected exception of $class to be thrown, but nothing was caught");
471471
}
472472
}

tests/unit/Codeception/Module/AssertsTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,15 @@ public function testExceptionFails()
5353
throw new Exception('here', 2);
5454
});
5555
}
56+
57+
/**
58+
* @expectedException PHPUnit\Framework\AssertionFailedError
59+
* @expectedExceptionMessageRegExp /RuntimeException/
60+
*/
61+
public function testOutputExceptionTimeWhenNothingCaught()
62+
{
63+
$module = new \Codeception\Module\Asserts(make_container());
64+
$module->expectException(RuntimeException::class, function () {
65+
});
66+
}
5667
}

0 commit comments

Comments
 (0)