Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Allow specifying duration as value for --order-by option…
… via CLI
- Loading branch information
1 parent
b2da7e6
commit 637846a
Showing
7 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/end-to-end/execution-order/_files/TestWithDifferentDurations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
* | ||
* 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); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/end-to-end/execution-order/_files/TestWithDifferentDurations.phpunit.result.cache.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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;}}} |
34 changes: 34 additions & 0 deletions
34
tests/end-to-end/execution-order/order-by-duration-via-cli.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--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')); | ||
|
||
$_SERVER['argv'][1] = '--no-configuration'; | ||
$_SERVER['argv'][2] = '--debug'; | ||
$_SERVER['argv'][3] = '--order-by=duration'; | ||
$_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) |