Improve docs to avoid Risky test warnings#94
Conversation
aik099
commented
Jun 26, 2025
- closes This test did not perform any assertions #61
- closes Error: risky test #62
There was a problem hiding this comment.
Pull Request Overview
This PR improves the documentation to prevent tests from being marked as Risky by providing clear instructions on how to update test case teardown methods.
- Updated the note section to advise adding assertion counts in tearDown.
- Replaced the old warning note with a modern admonition style.
Comments suppressed due to low confidence (1)
README.md:71
- [nitpick] Consider adding a brief explanation of why incrementing the assertion count and resetting it are required to bypass the Risky test warning. This additional context will help developers understand the purpose of this code snippet.
> To prevent tests from being marked as Risky (the `This test did not perform any assertions` message)
@pscheit , I've got this comment from you via an e-mail, but I wasn't able to find it on GitHub anymore. Anyway, here is the answer: When you use Hamcrest library, then it doesn't report back assertions made back to the PHPUnit. This way PHPUnit thinks, that it's something wrong with the test and reports it as risky. The changes made in this PR recommend adding a code to your test case class (or better your base test case class) to close that gap and make PHPUnit aware of Hamcrest performed assertions. |