Merge branch '2.x' into feature/compact-dataset-description

This commit is contained in:
Nuno Maduro
2023-02-13 23:32:02 +00:00
committed by GitHub
66 changed files with 1904 additions and 452 deletions

View File

@ -1,6 +1,6 @@
##teamcity[testSuiteStarted name='Tests\tests\Failure' locationHint='file://tests/.tests/Failure.php' flowId='1234']
##teamcity[testSuiteStarted name='Tests/tests/Failure' locationHint='file://tests/.tests/Failure.php' flowId='1234']
##teamcity[testStarted name='it can fail with comparison' locationHint='pest_qn://tests/.tests/Failure.php::it can fail with comparison' flowId='1234']
##teamcity[testFailed name='it can fail with comparison' message='Failed asserting that true matches expected false.' details='at src/Mixins/Expectation.php:312|nat src/Support/ExpectationPipeline.php:75|nat src/Support/ExpectationPipeline.php:79|nat src/Expectation.php:300|nat tests/.tests/Failure.php:6|nat src/Factories/TestCaseMethodFactory.php:106|nat src/Concerns/Testable.php:262|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:262|nat src/Concerns/Testable.php:217|nat src/Kernel.php:79' type='comparisonFailure' actual='true' expected='false' flowId='1234']
##teamcity[testFailed name='it can fail with comparison' message='Failed asserting that true matches expected false.' details='at src/Mixins/Expectation.php:342|nat src/Support/ExpectationPipeline.php:75|nat src/Support/ExpectationPipeline.php:79|nat src/Expectation.php:300|nat tests/.tests/Failure.php:6|nat src/Factories/TestCaseMethodFactory.php:105|nat src/Concerns/Testable.php:262|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:262|nat src/Concerns/Testable.php:217|nat src/Kernel.php:89' type='comparisonFailure' actual='true' expected='false' flowId='1234']
##teamcity[testFinished name='it can fail with comparison' duration='100000' flowId='1234']
##teamcity[testStarted name='it can be ignored because of no assertions' locationHint='pest_qn://tests/.tests/Failure.php::it can be ignored because of no assertions' flowId='1234']
##teamcity[testIgnored name='it can be ignored because of no assertions' message='This test did not perform any assertions' details='' flowId='1234']
@ -9,7 +9,7 @@
##teamcity[testIgnored name='it can be ignored because it is skipped' message='This test was ignored.' details='' flowId='1234']
##teamcity[testFinished name='it can be ignored because it is skipped' duration='100000' flowId='1234']
##teamcity[testStarted name='it can fail' locationHint='pest_qn://tests/.tests/Failure.php::it can fail' flowId='1234']
##teamcity[testFailed name='it can fail' message='oh noo' details='at tests/.tests/Failure.php:18|nat src/Factories/TestCaseMethodFactory.php:106|nat src/Concerns/Testable.php:262|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:262|nat src/Concerns/Testable.php:217|nat src/Kernel.php:79' flowId='1234']
##teamcity[testFailed name='it can fail' message='oh noo' details='at tests/.tests/Failure.php:18|nat src/Factories/TestCaseMethodFactory.php:105|nat src/Concerns/Testable.php:262|nat src/Support/ExceptionTrace.php:28|nat src/Concerns/Testable.php:262|nat src/Concerns/Testable.php:217|nat src/Kernel.php:89' flowId='1234']
##teamcity[testFinished name='it can fail' duration='100000' flowId='1234']
##teamcity[testStarted name='it is not done yet' locationHint='pest_qn://tests/.tests/Failure.php::it is not done yet' flowId='1234']
##teamcity[testIgnored name='it is not done yet' message='This test was ignored.' details='' flowId='1234']
@ -17,7 +17,7 @@
##teamcity[testStarted name='build this one.' locationHint='pest_qn://tests/.tests/Failure.php::build this one.' flowId='1234']
##teamcity[testIgnored name='build this one.' message='This test was ignored.' details='' flowId='1234']
##teamcity[testFinished name='build this one.' duration='100000' flowId='1234']
##teamcity[testSuiteFinished name='Tests\tests\Failure' flowId='1234']
##teamcity[testSuiteFinished name='Tests/tests/Failure' flowId='1234']
Tests: 2 failed, 1 risky, 2 todos, 1 skipped (2 assertions)
Duration: 1.00s

View File

@ -1,9 +1,9 @@
##teamcity[testSuiteStarted name='Tests\tests\SuccessOnly' locationHint='file://tests/.tests/SuccessOnly.php' flowId='1234']
##teamcity[testSuiteStarted name='Tests/tests/SuccessOnly' locationHint='file://tests/.tests/SuccessOnly.php' flowId='1234']
##teamcity[testStarted name='it can pass with comparison' locationHint='pest_qn://tests/.tests/SuccessOnly.php::it can pass with comparison' flowId='1234']
##teamcity[testFinished name='it can pass with comparison' duration='100000' flowId='1234']
##teamcity[testStarted name='can also pass' locationHint='pest_qn://tests/.tests/SuccessOnly.php::can also pass' flowId='1234']
##teamcity[testFinished name='can also pass' duration='100000' flowId='1234']
##teamcity[testSuiteFinished name='Tests\tests\SuccessOnly' flowId='1234']
##teamcity[testSuiteFinished name='Tests/tests/SuccessOnly' flowId='1234']
Tests: 2 passed (2 assertions)
Duration: 1.00s

View File

@ -49,7 +49,6 @@
--fail-on-risky .............................. Treat risky tests as failures
--fail-on-skipped .......................... Treat skipped tests as failures
--fail-on-warning .................... Treat tests with warnings as failures
--repeat <times> ...................................... Runs the test(s) repeatedly
--cache-result ............................ Write test results to cache file
--do-not-cache-result .............. Do not write test results to cache file
--order-by <order> Run tests in order: default|defects|duration|no-depends|random|reverse|size
@ -78,7 +77,6 @@
--log-teamcity <file> .............. Log test execution in TeamCity format to file
--testdox-html <file> ................. Write documentation in HTML format to file
--testdox-text <file> ................. Write documentation in Text format to file
--testdox-xml <file> ................... Write documentation in XML format to file
--log-events-text <file> ..................... Stream events as plain text to file
--log-events-verbose-text <file> Stream events as plain text to file (with telemetry information)
--no-logging .................................. Ignore logging configuration

View File

@ -29,7 +29,7 @@
✓ it does not append CoversNothing to other methods
✓ it throws exception if no class nor method has been found
PASS Tests\Features\DatasetsTests
PASS Tests\Features\DatasetsTests - 1 todo
✓ it throws exception if dataset does not exist
✓ it throws exception if dataset already exist
✓ it sets closures
@ -556,6 +556,18 @@
✓ it fails
✓ it fails with message
PASS Tests\Features\Expect\toHaveMethod
✓ pass
✓ failures
✓ failures with message
✓ not failures
PASS Tests\Features\Expect\toHaveMethods
✓ pass
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toHaveProperties
✓ pass
✓ failures
@ -732,7 +744,7 @@
✓ it allows access to the underlying expectNotToPerformAssertions method
✓ it allows performing no expectations without being risky
PASS Tests\Features\Todo
PASS Tests\Features\Todo - 3 todos
↓ something todo later
↓ something todo later chained
↓ something todo later chained and with function body
@ -833,7 +845,7 @@
✓ environment is set to Local when --ci option is not used
PASS Tests\Unit\Plugins\Retry
✓ it retries if --retry argument is used
✓ it orders by defects and stop on defects if when --retry is used
PASS Tests\Unit\Support\Backtrace
✓ it gets file name from called file
@ -886,6 +898,9 @@
PASS Tests\Visual\Help
✓ visual snapshot of help command output
PASS Tests\Visual\Parallel
✓ parallel
PASS Tests\Visual\SingleTestOrDirectory
✓ allows to run a single test
✓ allows to run a directory
@ -904,4 +919,5 @@
PASS Tests\Visual\Version
✓ visual snapshot of help command output
Tests: 4 incomplete, 4 todos, 18 skipped, 627 passed (1514 assertions)
Tests: 4 incomplete, 4 todos, 18 skipped, 627 passed (1514 assertions)

View File

@ -1,7 +1,7 @@
PASS Tests\Features\DatasetsTests
TODO Tests\Features\DatasetsTests - 1 todo
↓ forbids to define tests in Datasets dirs and Datasets.php files
PASS Tests\Features\Todo
TODO Tests\Features\Todo - 3 todos
↓ something todo later
↓ something todo later chained
↓ something todo later chained and with function body

View File

@ -0,0 +1,28 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
$object = new class
{
public function foo(): void
{
}
};
test('pass', function () use ($object) {
expect($object)->toHaveMethod('foo')
->and($object)->toHaveMethod('foo')
->and($object)->not->toHaveMethod('fooNull');
});
test('failures', function () use ($object) {
expect($object)->toHaveMethod('bar');
})->throws(ExpectationFailedException::class);
test('failures with message', function () use ($object) {
expect($object)->toHaveMethod(name: 'bar', message: 'oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () use ($object) {
expect($object)->not->toHaveMethod('foo');
})->throws(ExpectationFailedException::class);

View File

@ -0,0 +1,30 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
$object = new class
{
public function foo(): void
{
}
public function bar(): void
{
}
};
test('pass', function () use ($object) {
expect($object)->toHaveMethods(['foo', 'bar']);
});
test('failures', function () use ($object) {
expect($object)->toHaveMethods(['foo', 'bar', 'baz']);
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () use ($object) {
expect($object)->toHaveMethods(['foo', 'bar', 'baz'], 'oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () use ($object) {
expect($object)->not->toHaveMethods(['foo', 'bar']);
})->throws(ExpectationFailedException::class);

View File

@ -1,11 +1,12 @@
<?php
use Pest\Plugins\Parallel;
use Pest\Support\Str;
// HACK: we have to determine our $_SERVER['globalHook-]>calls baseline. This is because
// two other tests are executed before this one due to filename ordering.
$args = $_SERVER['argv'] ?? [];
$single = (isset($args[1]) && Str::endsWith(__FILE__, $args[1])) || ($_SERVER['PEST_PARALLEL'] ?? false);
$single = (isset($args[1]) && Str::endsWith(__FILE__, $args[1])) || Parallel::isWorker();
$offset = $single ? 0 : 2;
uses()->beforeAll(function () use ($offset) {

View File

@ -2,14 +2,13 @@
use Pest\Plugins\Retry;
beforeEach(fn () => Retry::$retrying = false);
afterEach(fn () => Retry::$retrying = false);
it('retries if --retry argument is used', function () {
it('orders by defects and stop on defects if when --retry is used ', function () {
$retry = new Retry();
$retry->handleArguments(['--retry']);
$arguments = $retry->handleArguments(['--retry']);
expect(Retry::$retrying)->toBeTrue();
expect($arguments)->toBe([
'--order-by=defects',
'--stop-on-failure',
]);
});

18
tests/Visual/Parallel.php Normal file
View File

@ -0,0 +1,18 @@
<?php
use Symfony\Component\Process\Process;
$run = function () {
$process = new Process(['php', 'bin/pest', '--parallel', '--processes=3', '--exclude-group=integration'], dirname(__DIR__, 2),
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
);
$process->run();
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput());
};
test('parallel', function () use ($run) {
expect($run())->toContain('Running 650 tests using 3 processes')
->toContain('Tests: 4 incomplete, 4 todos, 15 skipped, 627 passed (1546 assertions)');
});

View File

@ -1,5 +1,12 @@
<?php
function normalize_windows_os_output(string $text): string
{
$text = str_replace('\r', '', $text);
return str_replace('\\', '/', $text);
}
test('visual snapshot of team city', function (string $testFile) {
$testsPath = dirname(__DIR__)."/.tests/$testFile";
@ -28,13 +35,9 @@ test('visual snapshot of team city', function (string $testFile) {
};
if (getenv('REBUILD_SNAPSHOTS')) {
$outputContent = explode("\n", $output());
file_put_contents($snapshot, implode("\n", $outputContent));
file_put_contents($snapshot, normalize_windows_os_output($output()));
} elseif (! getenv('EXCLUDE')) {
$output = explode("\n", $output());
expect(implode("\n", $output))->toEqual(file_get_contents($snapshot));
expect(normalize_windows_os_output($output()))->toEqual(file_get_contents($snapshot));
}
})->with([
'Failure.php',