-
-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
I'm working on a simple abstraction built on top of http-server for making async APIs and I ran into the following issue - when I try to write a test to assert that an exception is thrown, TestCase::expectException() seems to be unaware of it actually happening. Take a look at this snippet:
<?php
class AwesomeTest extends AsyncTestCase
{
public function testOhNoes()
{
$this->expectException(Error::class);
yield call(function () {
throw new Error;
});
}
public function testYay()
{
$this->expectException(Error::class);
throw new Error;
}
}
And the output from PHPUnit:
1) AwesomeTest::testOhNoes
Error:
/home/jakobmats/workspace/empress/test/AwesomeTest.php:13
/home/jakobmats/workspace/empress/vendor/amphp/amp/lib/functions.php:60
/home/jakobmats/workspace/empress/test/AwesomeTest.php:14
/home/jakobmats/workspace/empress/vendor/amphp/amp/lib/Coroutine.php:60
/home/jakobmats/workspace/empress/vendor/amphp/amp/lib/functions.php:66
/home/jakobmats/workspace/empress/vendor/amphp/phpunit-util/src/AsyncTestCase.php:23
/home/jakobmats/.config/composer/vendor/phpunit/phpunit/src/TextUI/Command.php:201
/home/jakobmats/.config/composer/vendor/phpunit/phpunit/src/TextUI/Command.php:160
The other test case passes without problems. Any ideas why it happens? As far as I understand it the error should bubble up until it hits the top level so that PHPUnit is supposed to see it, no?
Metadata
Metadata
Assignees
Labels
No labels