diff --git a/phpunit.xsd b/phpunit.xsd
index 6eba998282c..2a32987971e 100644
--- a/phpunit.xsd
+++ b/phpunit.xsd
@@ -176,19 +176,19 @@
-
-
-
+
-
+
+
-
+
+
diff --git a/src/TextUI/Command.php b/src/TextUI/Command.php
index a25e9f54b55..b987d9562a9 100644
--- a/src/TextUI/Command.php
+++ b/src/TextUI/Command.php
@@ -1257,16 +1257,6 @@ private function handleOrderByOption(string $value): void
break;
- case 'reverse':
- $this->arguments['executionOrder'] = TestSuiteSorter::ORDER_REVERSED;
-
- break;
-
- case 'random':
- $this->arguments['executionOrder'] = TestSuiteSorter::ORDER_RANDOMIZED;
-
- break;
-
case 'defects':
$this->arguments['executionOrderDefects'] = TestSuiteSorter::ORDER_DEFECTS_FIRST;
@@ -1277,11 +1267,26 @@ private function handleOrderByOption(string $value): void
break;
+ case 'duration':
+ $this->arguments['executionOrder'] = TestSuiteSorter::ORDER_DURATION;
+
+ break;
+
case 'no-depends':
$this->arguments['resolveDependencies'] = false;
break;
+ case 'random':
+ $this->arguments['executionOrder'] = TestSuiteSorter::ORDER_RANDOMIZED;
+
+ break;
+
+ case 'reverse':
+ $this->arguments['executionOrder'] = TestSuiteSorter::ORDER_REVERSED;
+
+ break;
+
default:
$this->exitWithErrorMessage("unrecognized --order-by option: $order");
}
diff --git a/src/TextUI/Help.php b/src/TextUI/Help.php
index 869043d8ce7..ce0fd3af235 100644
--- a/src/TextUI/Help.php
+++ b/src/TextUI/Help.php
@@ -100,7 +100,7 @@ final class Help
['arg' => '--printer ', 'desc' => 'TestListener implementation to use'],
['spacer' => ''],
- ['arg' => '--order-by=', 'desc' => 'Run tests in order: default|reverse|random|defects|no-depends'],
+ ['arg' => '--order-by=', 'desc' => 'Run tests in order: default|defects|duration|no-depends|random|reverse'],
['arg' => '--random-order-seed=', 'desc' => 'Use a specific random seed for random order'],
['arg' => '--cache-result', 'desc' => 'Write test results to cache file'],
['arg' => '--do-not-cache-result', 'desc' => 'Do not write test results to cache file'],
diff --git a/src/Util/Configuration.php b/src/Util/Configuration.php
index b79916c843d..3db2a5b85f1 100644
--- a/src/Util/Configuration.php
+++ b/src/Util/Configuration.php
@@ -834,25 +834,35 @@ public function getPHPUnitConfiguration(): array
$result['resolveDependencies'] = false;
break;
- case 'reverse':
- $result['executionOrder'] = TestSuiteSorter::ORDER_REVERSED;
-
- break;
- case 'random':
- $result['executionOrder'] = TestSuiteSorter::ORDER_RANDOMIZED;
- break;
case 'defects':
$result['executionOrderDefects'] = TestSuiteSorter::ORDER_DEFECTS_FIRST;
break;
+
case 'depends':
$result['resolveDependencies'] = true;
break;
+
+ case 'duration':
+ $result['executionOrder'] = TestSuiteSorter::ORDER_DURATION;
+
+ break;
+
case 'no-depends':
$result['resolveDependencies'] = false;
+ break;
+
+ case 'random':
+ $result['executionOrder'] = TestSuiteSorter::ORDER_RANDOMIZED;
+
+ break;
+
+ case 'reverse':
+ $result['executionOrder'] = TestSuiteSorter::ORDER_REVERSED;
+
break;
}
}
diff --git a/tests/end-to-end/cli/_files/output-cli-help-color.txt b/tests/end-to-end/cli/_files/output-cli-help-color.txt
index ab5dbec3f43..a889abbb3c3 100644
--- a/tests/end-to-end/cli/_files/output-cli-help-color.txt
+++ b/tests/end-to-end/cli/_files/output-cli-help-color.txt
@@ -99,7 +99,7 @@
[32m--printer [36m[0m [0m TestListener implementation to use
[32m--order-by=[36m[0m [0m Run tests in order:
- default|reverse|random|defects|no-depends
+ default|defects|duration|no-depends|random|reverse
[32m--random-order-seed=[36m[0m [0m Use a specific random seed for random
order
[32m--cache-result [0m Write test results to cache file
diff --git a/tests/end-to-end/cli/_files/output-cli-usage.txt b/tests/end-to-end/cli/_files/output-cli-usage.txt
index 5134d0dcee3..ce9ae1eea13 100644
--- a/tests/end-to-end/cli/_files/output-cli-usage.txt
+++ b/tests/end-to-end/cli/_files/output-cli-usage.txt
@@ -77,7 +77,7 @@ Test Execution Options:
--testdox-exclude-group Exclude tests from the specified group(s)
--printer TestListener implementation to use
- --order-by= Run tests in order: default|reverse|random|defects|no-depends
+ --order-by= Run tests in order: default|defects|duration|no-depends|random|reverse
--random-order-seed= Use a specific random seed for random order
--cache-result Write test results to cache file
--do-not-cache-result Do not write test results to cache file
diff --git a/tests/end-to-end/execution-order/_files/TestWithDifferentDurations.php b/tests/end-to-end/execution-order/_files/TestWithDifferentDurations.php
new file mode 100644
index 00000000000..8d0b6f381a7
--- /dev/null
+++ b/tests/end-to-end/execution-order/_files/TestWithDifferentDurations.php
@@ -0,0 +1,28 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+use PHPUnit\Framework\TestCase;
+
+final class TestWithDifferentDurations extends TestCase
+{
+ public function testOne(): void
+ {
+ $this->assertTrue(true);
+ }
+
+ public function testTwo(): void
+ {
+ $this->assertTrue(true);
+ }
+
+ public function testThree(): void
+ {
+ $this->assertTrue(true);
+ }
+}
diff --git a/tests/end-to-end/execution-order/_files/TestWithDifferentDurations.phpunit.result.cache.txt b/tests/end-to-end/execution-order/_files/TestWithDifferentDurations.phpunit.result.cache.txt
new file mode 100644
index 00000000000..3a14002b065
--- /dev/null
+++ b/tests/end-to-end/execution-order/_files/TestWithDifferentDurations.phpunit.result.cache.txt
@@ -0,0 +1 @@
+C:37:"PHPUnit\Runner\DefaultTestResultCache":199:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:3:{s:35:"TestWithDifferentDurations::testOne";d:1.000;s:35:"TestWithDifferentDurations::testTwo";d:0.500;s:37:"TestWithDifferentDurations::testThree";d:1.500;}}}
diff --git a/tests/end-to-end/execution-order/_files/order-by-duration.phpunit.xml b/tests/end-to-end/execution-order/_files/order-by-duration.phpunit.xml
new file mode 100644
index 00000000000..2ef82a66223
--- /dev/null
+++ b/tests/end-to-end/execution-order/_files/order-by-duration.phpunit.xml
@@ -0,0 +1,11 @@
+
+
+
+ ./TestWithDifferentDurations.php
+
+
+
diff --git a/tests/end-to-end/execution-order/order-by-duration-via-cli.phpt b/tests/end-to-end/execution-order/order-by-duration-via-cli.phpt
new file mode 100644
index 00000000000..e87094847a3
--- /dev/null
+++ b/tests/end-to-end/execution-order/order-by-duration-via-cli.phpt
@@ -0,0 +1,33 @@
+--TEST--
+phpunit --order-by=duration ./tests/end-to-end/execution-order/_files/TestWithDifferentDurations.php
+--FILE--
+