Skip to content

Commit

Permalink
Fine tune FAQ answer
Browse files Browse the repository at this point in the history
  • Loading branch information
kelveny committed Jun 6, 2021
1 parent 5be5a30 commit 1fe0cc1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,17 @@ func TestMockVariadic(t *testing.T) {
### 4. Can mockcompose generate mocked implementation for functions?
<br/>

### __Answer__: If you've gone through FAQ answers above, you know that `mockcompose` of course can!
### __Answer__: Yes. `mockcompose` can group a set of functions into a generated Go class, the generated Go class has embedded mock object through which function behavior can be mocked.

`go generate` configuration: mocks.go
```go
//go:generate mockcompose -n mockFmt -p fmt -mock Sprintf
//go:generate mockcompose -n mockJson -p encoding/json -mock Marshal
```
With this configuration, `mockcompose` can generate mocking Go class `mockFmt` and `mockJson` that implement `Sprintf` and `Marshal` respectively. Callers of these functions can then use method/function local overrides to connect callouts of method/function to these generated Go classes.

These techniques have been used in examples of the questions above.

<br/>

### 5. How do I configure `go generate` in YAML?
Expand Down

0 comments on commit 1fe0cc1

Please sign in to comment.