Skip to content

Conversation

@aik099
Copy link
Member

@aik099 aik099 commented Jun 26, 2025

@aik099 aik099 requested a review from Copilot June 27, 2025 06:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@aik099 aik099 merged commit e37edf7 into hamcrest:master Jun 27, 2025
6 checks passed
@aik099 aik099 deleted the risky-test-docs branch June 27, 2025 06:45
@aik099
Copy link
Member Author

aik099 commented Jun 27, 2025

dont understand, how should this work? I then have changed code I have to exclude from committing?

Imho copying the phpunit.xml.dist to phpunit.xml and setting the option:
beStrictAboutTestsThatDoNotTestAnything="false"

should be the recommendation

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: risky test This test did not perform any assertions

1 participant