1

I have a contrived test case showcasing how multiple test cases can slow the entire execution time down, as even though each is quick on its own, they add up if waited for before executing the next.

I have created a repository for this:

k0pernikus/parallel-paratests

<?php namespace Kopernikus\ParallelParatests\Tests; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; class ItShouldTestInPallarel extends TestCase { #[DataProvider('delayProvider')] public function testItRunsTestsInParallel(int $delay) { sleep($delay); $this->assertTrue(true); } public static function delayProvider() { return array_map(function ($value) { return [$value]; }, array_fill(0, 10, 1)); } } 

In order speed up test execution time, I installed paratest:

composer require brianium/paratest --dev 

Now I expected the test to finish after 1 seconds.

I execute the test via phpstorm (and have enabled the paratest config), yet the entire test run still takes ~10s as each test is executed one after the other.

/bin/php /home/philipp/php/parallel-paratests/vendor/bin/paratest_for_phpstorm /home/philipp/php/parallel-paratests/vendor/phpunit/phpunit/phpunit --bootstrap /tmp/ide-phpstorm_bootstrap.php --filter Kopernikus\\ParallelParatests\\Tests\\ItShouldTestInPallarel --test-suffix ItShouldTestInPallarel.php /home/philipp/php/parallel-paratests/tests --teamcity Testing started at 5:48 PM ... PHPUnit 12.3.8 by Sebastian Bergmann and contributors. Runtime: PHP 8.4.12 Time: 00:10.034, Memory: 14.00 MB OK (10 tests, 10 assertions) Process finished with exit code 0 

Reading further, I may require --functional flag for paratest, yet have no clue as of yet how to pass that within PhpStorm.


I managed to get parallel test execution on bash terminal, yet not within PhpStorm:

~ ./vendor/bin/paratest /home/philipp/php/parallel-paratests/tests/ItShouldTestInPallarel.php --functional ParaTest v7.12.0 upon PHPUnit 12.3.8 by Sebastian Bergmann and contributors. Processes: 32 Runtime: PHP 8.4.12 .......... 10 / 10 (100%) Time: 00:01.215, Memory: 12.00 MB OK (10 tests, 10 assertions) 

I have no idea how to pass the --functional flag in phpstorm to paratest:

Run config for test case in phpstorm

2
  • Created follow up on the paratest issue tracker: github.com/paratestphp/paratest/issues/1011 Commented Sep 7 at 15:25
  • 1
    since paratest alone do it's job , i'm not sure that open and issue on paratest's github page is the right choice, i think you need to find the para plugin page for phpstorm and ask there ps: a dirty trick could be (not tested but you could give a try) edit /home/philipp/php/parallel-paratests/vendor/bin/paratest_for_phpstorm changing this: require PhpstormHelper::handleArgvFromPhpstorm($_SERVER['argv'], __DIR__ . '/paratest'); with this: require PhpstormHelper::handleArgvFromPhpstorm($_SERVER['argv'], __DIR__ . '/paratest --functional'); Commented Oct 14 at 10:45

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.