Compare commits

...

4 Commits

Author SHA1 Message Date
97dc32f9d2 release: v2.30.0 2023-12-28 10:36:40 +00:00
a3ab065343 chore: coding style 2023-12-28 10:36:30 +00:00
c390721ac3 chore: update snapshots 2023-12-28 10:34:22 +00:00
f83d758d4b feat: adds fails 2023-12-28 10:31:39 +00:00
8 changed files with 42 additions and 5 deletions

View File

@ -18,6 +18,7 @@ use Pest\Support\HigherOrderCallables;
use Pest\Support\NullClosure; use Pest\Support\NullClosure;
use Pest\Support\Str; use Pest\Support\Str;
use Pest\TestSuite; use Pest\TestSuite;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
@ -57,6 +58,14 @@ final class TestCall
$this->testSuite->beforeEach->get($this->filename)[0]($this); $this->testSuite->beforeEach->get($this->filename)[0]($this);
} }
/**
* Asserts that the test fails with the given message.
*/
public function fails(?string $message = null): self
{
return $this->throws(AssertionFailedError::class, $message);
}
/** /**
* Asserts that the test throws the given `$exceptionClass` when called. * Asserts that the test throws the given `$exceptionClass` when called.
*/ */

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string function version(): string
{ {
return '2.29.1'; return '2.30.0';
} }
function testDirectory(string $file = ''): string function testDirectory(string $file = ''): string

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.29.1. Pest Testing Framework 2.30.0.
USAGE: pest <file> [options] USAGE: pest <file> [options]

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.29.1. Pest Testing Framework 2.30.0.

View File

@ -898,6 +898,14 @@
✓ it skips with falsy closure condition ✓ it skips with falsy closure condition
✓ it can be used in higher order tests ✓ it can be used in higher order tests
PASS Tests\Features\Fail
✓ it may fail
✓ it may fail with the given message
PASS Tests\Features\Fails
✓ it may fail
✓ it may fail with the given message
WARN Tests\Features\Helpers WARN Tests\Features\Helpers
✓ it can set/get properties on $this ✓ it can set/get properties on $this
! it gets null if property do not exist → Undefined property Tests\Features\Helpers::$wqdwqdqw ! it gets null if property do not exist → Undefined property Tests\Features\Helpers::$wqdwqdqw
@ -1356,4 +1364,4 @@
WARN Tests\Visual\Version WARN Tests\Visual\Version
- visual snapshot of help command output - visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 966 passed (2286 assertions) Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 970 passed (2296 assertions)

11
tests/Features/Fail.php Normal file
View File

@ -0,0 +1,11 @@
<?php
use PHPUnit\Framework\AssertionFailedError;
it('may fail', function () {
$this->fail();
})->throws(AssertionFailedError::class);
it('may fail with the given message', function () {
$this->fail('this is a failure');
})->throws(AssertionFailedError::class, 'this is a failure');

9
tests/Features/Fails.php Normal file
View File

@ -0,0 +1,9 @@
<?php
it('may fail', function () {
$this->fail();
})->fails();
it('may fail with the given message', function () {
$this->fail('this is a failure');
})->fails('this is a failure');

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) { test('parallel', function () use ($run) {
expect($run('--exclude-group=integration')) expect($run('--exclude-group=integration'))
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 953 passed (2267 assertions)') ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 957 passed (2277 assertions)')
->toContain('Parallel: 3 processes'); ->toContain('Parallel: 3 processes');
})->skipOnWindows(); })->skipOnWindows();