Package gomock
Overview ▹
Index ▹
func InOrder ¶
func InOrder(calls ...*Call)
InOrder declares that the given calls should occur in order.
type Call ¶
Call represents an expected call to a mock.
type Call struct {
// contains filtered or unexported fields
}
func (*Call) After ¶
func (c *Call) After(preReq *Call) *Call
After declares that the call may only match after preReq has been exhausted.
func (*Call) AnyTimes ¶
func (c *Call) AnyTimes() *Call
AnyTimes allows the expectation to be called 0 or more times
func (*Call) Do ¶
func (c *Call) Do(f interface{}) *Call
Do declares the action to run when the call is matched. It takes an interface{} argument to support n-arity functions.
func (*Call) MaxTimes ¶
func (c *Call) MaxTimes(n int) *Call
MaxTimes limits the number of calls to n times. If AnyTimes or MinTimes have not been called, MaxTimes also sets the minimum number of calls to 0.
func (*Call) MinTimes ¶
func (c *Call) MinTimes(n int) *Call
MinTimes requires the call to occur at least n times. If AnyTimes or MaxTimes have not been called, MinTimes also sets the maximum number of calls to infinity.
func (*Call) Return ¶
func (c *Call) Return(rets ...interface{}) *Call
func (*Call) SetArg ¶
func (c *Call) SetArg(n int, value interface{}) *Call
SetArg declares an action that will set the nth argument's value, indirected through a pointer.
func (*Call) String ¶
func (c *Call) String() string
func (*Call) Times ¶
func (c *Call) Times(n int) *Call
type Controller ¶
A Controller represents the top-level control of a mock ecosystem. It defines the scope and lifetime of mock objects, as well as their expectations. It is safe to call Controller's methods from multiple goroutines.
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(t TestReporter) *Controller
func (*Controller) Call ¶
func (ctrl *Controller) Call(receiver interface{}, method string, args ...interface{}) []interface{}
func (*Controller) Finish ¶
func (ctrl *Controller) Finish()
func (*Controller) RecordCall ¶
func (ctrl *Controller) RecordCall(receiver interface{}, method string, args ...interface{}) *Call
type Matcher ¶
A Matcher is a representation of a class of values. It is used to represent the valid or expected arguments to a mocked method.
type Matcher interface { // Matches returns whether x is a match. Matches(x interface{}) bool // String describes what the matcher matches. String() string }
func Any ¶
func Any() Matcher
Constructors
func Eq ¶
func Eq(x interface{}) Matcher
func Nil ¶
func Nil() Matcher
func Not ¶
func Not(x interface{}) Matcher
type TestReporter ¶
A TestReporter is something that can be used to report test failures. It is satisfied by the standard library's *testing.T.
type TestReporter interface { Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) }
Subdirectories
Name | Synopsis |
---|---|
.. | |
mock_matcher |