Github.com/uber/mock: Difference between revisions
Jump to navigation
Jump to search
Bazel Integration with the
Line 15: | Line 15: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Bazel Integration= | =Bazel Integration with the <code>gomock</code> Rule= | ||
{{External|https://github.com/jmhodges/bazel_gomock#use}} | {{External|https://github.com/jmhodges/bazel_gomock#use}} | ||
==Attributes== | |||
===<tt>name</tt>=== | |||
===<tt>out</tt>=== | |||
=Programming Model= | =Programming Model= |
Revision as of 21:43, 16 July 2024
External
Internal
Overview
Installation
mockgen
To generate the mock code at stdout:
mockgen -package <name_of_the_package_mock_will_belong_to> <package_import_path> <InterfaceName>[,<InterfaceName>]
Bazel Integration with the gomock
Rule
Attributes
name
out
Programming Model
Setup Expectations
Define the Behavior of a Method
Configuring a mock to handle a specific method call.
someMock.EXPECT().SomeMethod(gomock.Any(), "some specific value").Return("some other value")
Note that if the method is not called at the end of the test, the mock will fail the test with:
missing call(s) to *mock_pkg.MockSomething.SomeMethod(...) aborting test due to missing call(s)