-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Explain better how to enable the ClockMock annotation #7503
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
Conversation
I think that the documentation in this part is a bit lacking. It says that you're enabling the mock in this way, but it's not explicit. It seems at a first glance that in this way your whole test will have mocked time function, when instead it's true only for function calls inside your test method, not outside. I had to use this a lot when the class that I was testing had time function calls, and I had to dive into the source code to understand that I had to do a manual registration of each class where I want to mock the time function calls. Maybe it's better to expand this issue's scope? |
If you don't want to use the ``@group time-sensitive`` annotation, you can | ||
register the ``ClockMock`` class manually by calling | ||
``ClockMock::register(__CLASS__)`` and ``ClockMock::withClockMock(true)`` | ||
before the test and ``ClockMock::withClockMock(false)`` after the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using then
instead of repeating and
? That might be easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. We say: "do XX and YY before ... and ZZ after ..." Which "and" should I replace by "then" ? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose:
[...] register the ``ClockMock`` class manually by calling
``ClockMock::register(__CLASS__)`` and ``ClockMock::withClockMock(true)``
before the test then ``ClockMock::withClockMock(false)`` after the test.
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new version is less readable 🤓 And this part is hard to read, don't you think? --> the test then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it would deserve a comma after test, but I trust you to choose the best way (that includes ignoring my comment :) ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right ... let mergers (@xabbuh ?) deal with this decision and change it if needed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thank you Javier. |
…viereguiluz) This PR was merged into the 2.8 branch. Discussion ---------- Explain better how to enable the ClockMock annotation This fixes #7500. Commits ------- 13baa4d Explain better how to enable the ClockMock annotation
This fixes #7500.