From 1a277d7e1a09761b15284b7817669bc3429d52a5 Mon Sep 17 00:00:00 2001 From: Lasse R Date: Tue, 26 Dec 2023 16:49:28 +0100 Subject: [PATCH 1/8] Document type coverage reporting --- type-coverage.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/type-coverage.md b/type-coverage.md index e6c0b5a..e72e90d 100644 --- a/type-coverage.md +++ b/type-coverage.md @@ -48,6 +48,12 @@ Just like code coverage, type coverage can also be enforced. To ensure any code ./vendor/bin/pest --type-coverage --min=100 ``` +## Different Formats + +Pest support reporting type coverage to a file as well: + +- `--coverage-clover=`: Save the type coverage report in JSON format to a specified file. + --- In the chapter, we have discussed Pest's Type Coverage plugin and how it can be used to measure the percentage of code that is covered by type declarations. In the following chapter, we explain how can you use Snapshots to test your code: [Snapshot Testing](/docs/snapshot-testing) From e6cee0719720209ad3fc3d09bd64a0cfe31445c4 Mon Sep 17 00:00:00 2001 From: Lasse R Date: Tue, 26 Dec 2023 16:50:27 +0100 Subject: [PATCH 2/8] Change command name --- type-coverage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type-coverage.md b/type-coverage.md index e72e90d..d1a2b38 100644 --- a/type-coverage.md +++ b/type-coverage.md @@ -52,7 +52,7 @@ Just like code coverage, type coverage can also be enforced. To ensure any code Pest support reporting type coverage to a file as well: -- `--coverage-clover=`: Save the type coverage report in JSON format to a specified file. +- `--type-coverage-json=`: Save the type coverage report in JSON format to a specified file. --- From 0a4e2d3685973cc0764d7d1247b07b0410a792d7 Mon Sep 17 00:00:00 2001 From: Lasse R Date: Tue, 26 Dec 2023 16:52:52 +0100 Subject: [PATCH 3/8] Update type-coverage.md --- type-coverage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type-coverage.md b/type-coverage.md index d1a2b38..f77a4f3 100644 --- a/type-coverage.md +++ b/type-coverage.md @@ -50,7 +50,7 @@ Just like code coverage, type coverage can also be enforced. To ensure any code ## Different Formats -Pest support reporting type coverage to a file as well: +Pest support reporting type coverage to a file: - `--type-coverage-json=`: Save the type coverage report in JSON format to a specified file. From e3d007b0a5678212f50d898dbfdcb66de3b30fd7 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 26 Dec 2023 16:12:46 +0000 Subject: [PATCH 4/8] Update type-coverage.md --- type-coverage.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/type-coverage.md b/type-coverage.md index f77a4f3..2cdb427 100644 --- a/type-coverage.md +++ b/type-coverage.md @@ -50,9 +50,11 @@ Just like code coverage, type coverage can also be enforced. To ensure any code ## Different Formats -Pest support reporting type coverage to a file: +In additionm, Pest support reporting the type coverage to a specific file: -- `--type-coverage-json=`: Save the type coverage report in JSON format to a specified file. +```bash +./vendor/bin/pest --type-coverage --min=100 --type-coverage-json=my-report.json +``` --- From e64e72db5560e708f285eb8f39ed69d484e54d53 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 27 Dec 2023 13:46:01 +0100 Subject: [PATCH 5/8] docs: fix wrong format --- cli-api-reference.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli-api-reference.md b/cli-api-reference.md index 4cddd45..4608fe2 100644 --- a/cli-api-reference.md +++ b/cli-api-reference.md @@ -29,8 +29,8 @@ In the preceding chapters of the Pest documentation, we have covered numerous CL - `--list-groups`: List available test groups. - `--group `: Only run tests from the specified group(s). - `--exclude-group `: Exclude tests from the specified group(s). -- `--covers `: Only run tests that intend to cover . -- `--uses `: Only run tests that intend to use . +- `--covers `: Only run tests that intend to cover ``. +- `--uses `: Only run tests that intend to use ``. - `--list-tests`: List available tests. - `--list-tests-xml `: List available tests in XML format. - `--filter `: Filter which tests to run From d5751d8fca57f0b9d1dafb18e30408cdfb36dcd2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 28 Dec 2023 10:48:08 +0000 Subject: [PATCH 6/8] Adds `fail` and `fails` documentation --- exceptions.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/exceptions.md b/exceptions.md index ce2a8bf..1157863 100644 --- a/exceptions.md +++ b/exceptions.md @@ -61,6 +61,38 @@ it('throws no exceptions', function () { })->throwsNoExceptions(); ``` +Sometimes, you may want to simply mark a test as failed. You can use the `fail()` method to do so. + +```php +it('fail', function () { + $this->fail(); +}); +``` + +You may also provide a message to the `fail()` method. + +```php +it('fail', function () { + $this->fail('Something went wrong.'); +}); +``` + +In addition, you can also use the `fails()` method to verify the test fails. + +```php +it('fails', function () { + throw new Exception('Something happened.'); +})->fails(); +``` + +Just like the `fail()` method, you may also provide a message to the `fails()` method. + +```php +it('fails', function () { + throw new Exception('Something happened.'); +})->fails('Something went wrong.'); +``` + --- After learning how to write tests that assert exceptions, the next step is to explore "Test Filtering". This feature allows you to efficiently run specific tests based on criteria like test name, dirty files, and more: [Filtering Tests →](/docs/filtering-tests) From 95425dc6e68f2186a824a4ebb154cadcaeb4aeac Mon Sep 17 00:00:00 2001 From: Tyler Date: Mon, 8 Jan 2024 08:20:09 -0600 Subject: [PATCH 7/8] Fix typo --- type-coverage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type-coverage.md b/type-coverage.md index 2cdb427..0a86832 100644 --- a/type-coverage.md +++ b/type-coverage.md @@ -50,7 +50,7 @@ Just like code coverage, type coverage can also be enforced. To ensure any code ## Different Formats -In additionm, Pest support reporting the type coverage to a specific file: +In addition, Pest support reporting the type coverage to a specific file: ```bash ./vendor/bin/pest --type-coverage --min=100 --type-coverage-json=my-report.json From e6ddcf8f8f9a573e82166ab6282ba531dec926a4 Mon Sep 17 00:00:00 2001 From: Owen Voke Date: Mon, 8 Jan 2024 14:52:12 +0000 Subject: [PATCH 8/8] docs: resolve grammar --- type-coverage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/type-coverage.md b/type-coverage.md index 0a86832..d522b1a 100644 --- a/type-coverage.md +++ b/type-coverage.md @@ -50,7 +50,7 @@ Just like code coverage, type coverage can also be enforced. To ensure any code ## Different Formats -In addition, Pest support reporting the type coverage to a specific file: +In addition, Pest supports reporting the type coverage to a specific file: ```bash ./vendor/bin/pest --type-coverage --min=100 --type-coverage-json=my-report.json