Skip to content

Commit

Permalink
Enhancement: Allow using duration option for execution order
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed May 6, 2019
1 parent fceedb0 commit 3e79f77
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Util/Configuration.php
Expand Up @@ -853,6 +853,10 @@ public function getPHPUnitConfiguration(): array
case 'no-depends':
$result['resolveDependencies'] = false;

break;
case 'duration':
$result['executionOrder'] = TestSuiteSorter::ORDER_DURATION;

break;
}
}
Expand Down
@@ -0,0 +1,11 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
executionOrder="duration"
>
<testsuites>
<testsuite name="order-by-duration">
<directory>.</directory>
</testsuite>
</testsuites>
</phpunit>
@@ -0,0 +1,35 @@
--TEST--
phpunit --order-by=duration ./tests/end-to-end/execution-order/_files/TestWithDifferentDurations.php
--FILE--
<?php

$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/_files/TestWithDifferentDurations.phpunit.result.cache.txt'));

$phpunitXmlConfig = __DIR__ . '/_files/order-by-duration.phpunit.xml';

$_SERVER['argv'][1] = '--configuration=' . $phpunitXmlConfig;
$_SERVER['argv'][2] = '--debug';
$_SERVER['argv'][4] = '--cache-result';
$_SERVER['argv'][5] = '--cache-result-file=' . $tmpResultCache;
$_SERVER['argv'][6] = 'TestWithDifferentDurations';
$_SERVER['argv'][7] = __DIR__ . '/_files/TestWithDifferentDurations.php';

require __DIR__ . '/../../bootstrap.php';
PHPUnit\TextUI\Command::main();

unlink($tmpResultCache);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Test 'TestWithDifferentDurations::testTwo' started
Test 'TestWithDifferentDurations::testTwo' ended
Test 'TestWithDifferentDurations::testOne' started
Test 'TestWithDifferentDurations::testOne' ended
Test 'TestWithDifferentDurations::testThree' started
Test 'TestWithDifferentDurations::testThree' ended


Time: %s, Memory: %s

OK (3 tests, 3 assertions)

0 comments on commit 3e79f77

Please sign in to comment.