diff --git a/src/Exceptions/InvalidPestCommand.php b/src/Exceptions/InvalidPestCommand.php index 5a5c153d..388a7b65 100644 --- a/src/Exceptions/InvalidPestCommand.php +++ b/src/Exceptions/InvalidPestCommand.php @@ -19,6 +19,6 @@ final class InvalidPestCommand extends InvalidArgumentException implements Excep */ public function __construct() { - parent::__construct('Please run `./vendor/bin/pest` instead of `/vendor/bin/phpunit`.'); + parent::__construct('Please run [./vendor/bin/pest] instead.'); } } diff --git a/src/Plugins/Coverage.php b/src/Plugins/Coverage.php index 18c1aa39..592db5a6 100644 --- a/src/Plugins/Coverage.php +++ b/src/Plugins/Coverage.php @@ -113,6 +113,9 @@ final class Coverage implements AddsOutput, HandlesArguments } } + + $this->output->writeln(['']); + return $exitCode; } } diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index 17b75862..209f2fa5 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -11,6 +11,8 @@ use SebastianBergmann\CodeCoverage\Node\File; use SebastianBergmann\Environment\Runtime; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Terminal; +use function Termwind\render; +use function Termwind\renderUsing; /** * @internal @@ -73,15 +75,6 @@ final class Coverage $totalCoverage = $codeCoverage->getReport()->percentageOfExecutedLines(); - $output->writeln( - sprintf( - ' Cov: %s', - $totalCoverage->asString() - ) - ); - - $output->writeln(''); - /** @var Directory $report */ $report = $codeCoverage->getReport(); @@ -112,7 +105,7 @@ final class Coverage ? '100.0' : number_format($file->percentageOfExecutedLines()->asFloat(), 1, '.', ''); - $takenSize = strlen($rawName . $percentage) + 4 + $linesExecutedTakenSize; // adding 3 space and percent sign + $takenSize = strlen($rawName . $percentage) + 2 + $linesExecutedTakenSize; // adding 3 space and percent sign $percentage = sprintf( '%s', @@ -121,13 +114,28 @@ final class Coverage ); $output->writeln(sprintf( - ' %s %s %s %%', + ' %s %s %s %%', $name, str_repeat('.', max($dottedLineLength - $takenSize, 1)), $percentage )); } + + $totalCoverageAsString = $totalCoverage->asFloat() === 0.0 + ? '0.0' + : number_format($totalCoverage->asFloat(), 1, '.', ''); + + renderUsing($output); + render(<< +
+
+ Total: {$totalCoverageAsString} % +
+ + HTML); + return $totalCoverage->asFloat(); } diff --git a/tests/.snapshots/allows-to-run-a-directory.txt b/tests/.snapshots/allows-to-run-a-directory.txt index aaf96389..b64fc582 100644 --- a/tests/.snapshots/allows-to-run-a-directory.txt +++ b/tests/.snapshots/allows-to-run-a-directory.txt @@ -4,4 +4,4 @@ PASS Tests\Fixtures\ExampleTest ✓ it example 2 - Tests: 2 passed + Tests: 2 passed (2 assertions) diff --git a/tests/.snapshots/allows-to-run-a-single-test.txt b/tests/.snapshots/allows-to-run-a-single-test.txt index 0812d708..7b7f5608 100644 --- a/tests/.snapshots/allows-to-run-a-single-test.txt +++ b/tests/.snapshots/allows-to-run-a-single-test.txt @@ -1,4 +1,4 @@ PASS Tests\Fixtures\DirectoryWithTests\ExampleTest ✓ it example 1 - Tests: 1 passed + Tests: 1 passed (1 assertions) diff --git a/tests/.snapshots/disable-decorating-printer.txt b/tests/.snapshots/disable-decorating-printer.txt index dc804c2f..9833da30 100644 --- a/tests/.snapshots/disable-decorating-printer.txt +++ b/tests/.snapshots/disable-decorating-printer.txt @@ -1,5 +1,5 @@ PASS Tests\Fixtures\DirectoryWithTests\ExampleTest - ✓ it example 1 + ✓ it example 1 - Tests: 1 passed + Tests: 1 passed (1 assertions) diff --git a/tests/.snapshots/has-ascii-chars.txt b/tests/.snapshots/has-ascii-chars.txt index 403f6ac7..0e60bb44 100644 --- a/tests/.snapshots/has-ascii-chars.txt +++ b/tests/.snapshots/has-ascii-chars.txt @@ -1,5 +1,4 @@ -  PASS  Tests\Fixtures\DirectoryWithTests\ExampleTest - ✓ it example 1 + ✓ it example 1 - Tests: 1 passed + Tests: 1 passed (1 assertions) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 2f7120ba..2ca81b1e 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -482,8 +482,8 @@ ✓ not failures with nested key ✓ not failures with plain key with dots ✓ not failures with correct value - ✓ not failures with correct value and with nested key - ✓ not failures with correct value and with plain key with dots + ✓ not failures with correct value and with nested key + ✓ not failures with correct value and with plain key with dots PASS Tests\Features\Expect\toHaveKeys ✓ pass @@ -614,8 +614,8 @@ PASS Tests\Features\PendingHigherOrderTests ✓ get 'foo' - ✓ get 'foo' → get 'bar' → expect true → toBeTrue - ✓ get 'foo' → expect true → toBeTrue + ✓ get 'foo' → get 'bar' → expect true → toBeTrue + ✓ get 'foo' → expect true → toBeTrue WARN Tests\Features\Skip ✓ it do not skips @@ -770,5 +770,4 @@ WARN Tests\Visual\TeamCity - it is can successfully call all public methods → Not supported yet. - Tests: 4 incompleted, 18 skipped, 515 passed - \ No newline at end of file + Tests: 4 incompleted, 18 skipped, 515 passed (1299 assertions) diff --git a/tests/Visual/Help.php b/tests/Visual/Help.php index 348c6852..642c9ae8 100644 --- a/tests/Visual/Help.php +++ b/tests/Visual/Help.php @@ -16,7 +16,7 @@ test('visual snapshot of help command output', function () { } $output = function () { - $process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'])); + $process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help'], null, ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'])); $process->run(); diff --git a/tests/Visual/SingleTestOrDirectory.php b/tests/Visual/SingleTestOrDirectory.php index 41a6a46c..d0fbb0a7 100644 --- a/tests/Visual/SingleTestOrDirectory.php +++ b/tests/Visual/SingleTestOrDirectory.php @@ -3,7 +3,9 @@ use Symfony\Component\Process\Process; $run = function (string $target, $decorated = false) { - $process = new Process(['php', 'bin/pest', $target, '--colors=always'], dirname(__DIR__, 2)); + $process = new Process(['php', 'bin/pest', $target, '--colors=always'], dirname(__DIR__, 2), + ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'], + ); $process->run(); @@ -29,6 +31,7 @@ test('allows to run a directory', function () use ($run, $snapshot) { })->skip(PHP_OS_FAMILY === 'Windows'); it('has ascii chars', function () use ($run, $snapshot) { + file_put_contents(__DIR__.'/output.txt', $run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true)); expect($run('tests/Fixtures/DirectoryWithTests/ExampleTest.php', true))->toContain($snapshot('has-ascii-chars')); })->skip(PHP_OS_FAMILY === 'Windows'); @@ -38,7 +41,7 @@ it('disable decorating printer when colors is set to never', function () use ($s './bin/pest', '--colors=never', 'tests/Fixtures/DirectoryWithTests/ExampleTest.php', - ], dirname(__DIR__, 2)); + ], dirname(__DIR__, 2), ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']); $process->run(); $output = $process->getOutput(); expect($output)->toContain($snapshot('disable-decorating-printer')); diff --git a/tests/Visual/Success.php b/tests/Visual/Success.php index a573aaf6..391c8d7b 100644 --- a/tests/Visual/Success.php +++ b/tests/Visual/Success.php @@ -12,7 +12,7 @@ test('visual snapshot of test suite on success', function () { $process = (new Symfony\Component\Process\Process( ['php', 'bin/pest'], dirname($testsPath), - ['EXCLUDE' => 'integration', 'REBUILD_SNAPSHOTS' => false, 'PARATEST' => 0, 'COLLISION_PRINTER' => 'DefaultPrinter'], + ['EXCLUDE' => 'integration', 'REBUILD_SNAPSHOTS' => false, 'PARATEST' => 0, 'COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'], )); $process->run();