-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
In my use case, I'd like to provide a convenient way for developers to run their test functions in coroutine containers like below:
class FooTest extends TestCase
{
use RunTestsInCoroutine;
// this test function is expected to be executed inside coroutine container
public function testFoo()
{
//...
}
}For my current implementation, I try to use setName function to proxy the real test function. By this way the test function will be proxied and wrapped in coroutine container in the proxied function.
final protected function runTest(): mixed
{
if ($this->shouldRunInCoroutine()) {
$this->realTestName = $this->name();
parent::setName('runTestsInCoroutine');
}
return parent::runTest();
}
final protected function runTestsInCoroutine(...$arguments)
{
parent::setName($this->realTestName);
Coroutine\run(
fn () => $this->{$this->realTestName}(...$arguments)
);
}However, I found this approach is not going to work any more because runTest function is marked private in: 8f0f820
I was wondering what the best practice is to proxy the test function to decorate the test functions.
Metadata
Metadata
Assignees
Labels
No labels