mockit

package
v0.0.0-...-218979b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

type Mock interface {

	// Disable disable the mock, so interactions will be with real objects
	Disable()

	// Enable restore the mock
	Enable()

	// Verify fails the test if a call with the specified arguments wasn't made
	Verify(in ...interface{})

	// With configures the mock to respond to the specified arguments
	With(values ...interface{}) Stub
}

Mock contains methods to mock a call with specified arguments, and verify it

func MockFunc

func MockFunc(t *testing.T, targetFn interface{}) Mock

MockFunc creates a new Mock to mock a function

func MockMethod

func MockMethod(t *testing.T, instance interface{}, method interface{}) Mock

MockMethod creates a new Mock to mock an instance method

func MockMethodForAll

func MockMethodForAll(t *testing.T, instance interface{}, method interface{}) Mock

MockMethodForAll creates a new Mock to mock the method for any instance of the specified type

type Stub

type Stub interface {

	// CallRealMethod makes sure that the mock perform a call to the real method
	CallRealMethod()

	// Return makes sure the mock to return the specified values
	Return(values ...interface{})

	// ReturnDefaults makes sure the mock to return the default outputs (zero values)
	ReturnDefaults()
}

Stub contains method to mock a specific method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL