Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve fail() and fails() doc #253

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,37 @@ it('throws no exceptions', function () {
Sometimes, you may want to simply mark a test as failed. You can use the `fail()` method to do so.

```php
it('fail', function () {
it('fails', function () {
$this->fail();
});
```

You may also provide a message to the `fail()` method.

```php
it('fail', function () {
it('fails', function () {
$this->fail('Something went wrong.');
});
```

In addition, you can also use the `fails()` method to verify the test fails.
In addition, you can also use the `fails()` method to verify if a test fails.

```php
it('fails', function () {
throw new Exception('Something happened.');
$this->fail('Something happened.');
})->fails();
```

Just like the `fail()` method, you may also provide a message to the `fails()` method.
You can also assert the failure reason by providing a message to the `fails()` method.

```php
it('fails', function () {
throw new Exception('Something happened.');
})->fails('Something went wrong.');
it('fails as expected', function () {
$this->fail('Something happened.');
})->fails('Something happened.'); // Pass

it('fails in an unexpected way', function () {
$this->fail('Something unexpected happened.');
})->fails('Something happened.'); // Fail
```

---
Expand Down