added go:generate example
This commit is contained in:
17
README.md
17
README.md
@@ -77,6 +77,23 @@ func CompleteSignUp(to string, sender EmailSender) {
|
||||
|
||||
The mocked structure implements the interface, where each method calls the associated function field.
|
||||
|
||||
### Using go generate
|
||||
|
||||
At the top of the file containing the interface you wish to mock, you can use
|
||||
`go generate` to specify the interface to mock:
|
||||
|
||||
```
|
||||
package test
|
||||
|
||||
//go:generate moq -out myface_test.go . MyFace
|
||||
|
||||
type MyFace interface {
|
||||
Method() string
|
||||
}
|
||||
```
|
||||
|
||||
Then navigate to the directory in a shell, and run `go generate`.
|
||||
|
||||
## Tips
|
||||
|
||||
* Keep mocked logic inside the test that is using it
|
||||
|
Reference in New Issue
Block a user