hellomock

package
v0.0.0-...-f10d331 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 1 Imported by: 0

README

注意点

  • mockgen的使用:1.先创建mock文件夹,2.mockgen -source=hellomock.go > mock/mock_Talker.go
  • gomock.Eq("王尼玛"),Eq方法要求测试用例里面的调用参数,一定要等于Eq方法设置的值。这也就是给定参数张全蛋的时候会发生错误的原因
  • gomock.Any()gomock.Eq相反,也就是可以传入任何值
  • Return方法就是给定函数的返回

参考资料

运行结果

t.Log(company.Meeting("王尼玛"))

Imgur

t.Log(company.Meeting("张全蛋"))

Imgur

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Company

type Company struct {
	Usher Talker
}

func NewCompany

func NewCompany(t Talker) *Company

func (*Company) Meeting

func (c *Company) Meeting(guestName string) string

type Person

type Person struct {
	// contains filtered or unexported fields
}

func NewPerson

func NewPerson(name string) *Person

func (*Person) SayHello

func (p *Person) SayHello(name string) string

type Talker

type Talker interface {
	SayHello(word string) (response string)
}

Directories

Path Synopsis
Package mock_hellomock is a generated GoMock package.
Package mock_hellomock is a generated GoMock package.

Jump to

Keyboard shortcuts

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