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

mock: Remove or Disable logging output in mock.AssertExpectations #1358

Closed
hikyaru-suzuki opened this issue Mar 8, 2023 · 2 comments · Fixed by #1360
Closed

mock: Remove or Disable logging output in mock.AssertExpectations #1358

hikyaru-suzuki opened this issue Mar 8, 2023 · 2 comments · Fixed by #1360
Labels
bug pkg-mock Any issues related to Mock

Comments

@hikyaru-suzuki
Copy link
Contributor

hikyaru-suzuki commented Mar 8, 2023

I am looking to remove the log output from mock.AssertExpectations runs. There have been several similar issues before (#782, #414) and the reason I want to remove them is similar to these. I am currently using gomock, but am considering moving to testify/mock, which supports generics, and these outputs themselves can be a bottleneck in testing large repositories where I have more than 10,000 test cases to deal with.
I am thinking of submitting a Pull Request, especially since there seems to be no progress. However, I am not familiar with this repository and am not sure whether to keep backward compatibility or not.
If you don't need backward compatibility, this is a very easy job. Simply remove or disable the following line:

t.Logf(reason)

Conversely, if backward compatibility is required, I don't know how to implement this, but there are several options, such as defining a public function in the testify/mock package to disable logging, or providing an environment variable to prevent logging from being output. I would love to hear your ideas!

@brackendawson
Copy link
Collaborator

I think it should be moved up one line, not removed, so that it still logs when the assertion fails. But otherwise agree.

@dolmen
Copy link
Collaborator

dolmen commented Jul 5, 2023

#1360 seems to be the right fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pkg-mock Any issues related to Mock
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants