Skip to content

Commit e37edf7

Browse files
authored
Improve docs to avoid Risky test warnings (#94)
* Improve docs to avoid Risky test warnings * Improve formatting
1 parent 0f51914 commit e37edf7

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,21 @@ assertThat($result === true);
6767
assertThat(true, is(true));
6868
```
6969

70-
:warning: **NOTE:** the global proxy-functions aren't autoloaded by default, so you will need to load them first:
71-
72-
```php
73-
\Hamcrest\Util::registerGlobalFunctions();
74-
```
70+
> [!NOTE]
71+
> To prevent tests from being marked as Risky (the `This test did not perform any assertions` message)
72+
> add this code to your test case `tearDown` method:
73+
>
74+
> ```php
75+
> $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount());
76+
> \Hamcrest\MatcherAssert::resetCount();
77+
> ```
78+
79+
> [!WARNING]
80+
> the global proxy-functions aren't autoloaded by default, so you will need to load them first:
81+
>
82+
> ```php
83+
> \Hamcrest\Util::registerGlobalFunctions();
84+
> ```
7585
7686
For brevity, all of the examples below use the proxy-functions.
7787

0 commit comments

Comments
 (0)