Posts

Showing posts with the label mock

Mockery in golang

This library is used for testing in golang https://github.com/vektra/mockery Installation go get github.com/vektra/mockery/... if happened errors then types go get github.com/vektra/mockery/cmd/mockery package test type Stringer interface { String () string } Run:  mockery -name=Stringer  and the following will be output to  mocks/Stringer.go : package mocks import " github.com/stretchr/testify/mock " type Stringer struct { mock. Mock } func ( m * Stringer ) String () string { ret := m. Called () var r0 string if rf , ok := ret. Get ( 0 ).( func () string ); ok { r0 = rf () } else { r0 = ret. Get ( 0 ).( string ) } return r0 }