Adds a new method, isInParallel, to the Testable trait to allow a test to determine its parallel status.

This commit is contained in:
luke
2021-08-10 14:34:10 +01:00
parent bcab4224fb
commit 5c592928d4
4 changed files with 31 additions and 2 deletions

View File

@ -304,4 +304,12 @@ trait Testable
{
return ltrim(self::class, 'P\\');
}
/**
* Determine whether this test case is being executed in a parallel environment.
*/
public function isInParallel(): bool
{
return TestSuite::getInstance()->isInParallel;
}
}

View File

@ -2,6 +2,7 @@
declare(strict_types=1);
use Pest\Concerns\Testable;
use Pest\Datasets;
use Pest\Expectation;
use Pest\PendingObjects\AfterEachCall;
@ -85,7 +86,7 @@ if (!function_exists('test')) {
* is the test description; the second argument is
* a closure that contains the test expectations.
*
* @return TestCall|TestCase|mixed
* @return TestCall|TestCase|Testable|mixed
*/
function test(string $description = null, Closure $closure = null)
{