Skip to content

feat: Add support for requiring that all non-nil methods be called#244

Open
nicholascapo wants to merge 1 commit intomatryer:mainfrom
axioscode:add_with_require_calls_flag
Open

feat: Add support for requiring that all non-nil methods be called#244
nicholascapo wants to merge 1 commit intomatryer:mainfrom
axioscode:add_with_require_calls_flag

Conversation

@nicholascapo
Copy link
Copy Markdown

At $day_job we have a helper that sets a mock function, and then resets it after the test is done (using t.Cleanup()).
When we have a moq with a nil function that gets called, the test panics, and then we implement the mocked function.

This change adds support for making the reverse assertion: Non-nil mock functions must be called in the tests.
If a non-nil function has not been called when the test ends, the helper fails the test, and then we can remove the mock function.

This might not be useful for everyone, so we add a -with-require-calls CLI flag, and the RequireCalls() function only returns an error.

Signed-off-by: Nicholas Capo <nicholas@capo.tech>
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.

1 participant