Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pestphp/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jan 10, 2024
2 parents e5b53da + 3638020 commit 12c768a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli-api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ In the preceding chapters of the Pest documentation, we have covered numerous CL
- `--list-groups`: List available test groups.
- `--group <name>`: Only run tests from the specified group(s).
- `--exclude-group <name>`: Exclude tests from the specified group(s).
- `--covers <name>`: Only run tests that intend to cover <name>.
- `--uses <name>`: Only run tests that intend to use <name>.
- `--covers <name>`: Only run tests that intend to cover `<name>`.
- `--uses <name>`: Only run tests that intend to use `<name>`.
- `--list-tests`: List available tests.
- `--list-tests-xml <file>`: List available tests in XML format.
- `--filter <pattern>`: Filter which tests to run
Expand Down
32 changes: 32 additions & 0 deletions exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions type-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ Just like code coverage, type coverage can also be enforced. To ensure any code
./vendor/bin/pest --type-coverage --min=100
```

## Different Formats

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
```

---

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)

0 comments on commit 12c768a

Please sign in to comment.