Skip to content

Commit

Permalink
Add placeholder example to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneHowearth authored and ernesto-jimenez committed Mar 19, 2018
1 parent 33951ec commit 380174f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Expand Up @@ -164,6 +164,29 @@ func TestSomething(t *testing.T) {
// assert that the expectations were met
testObj.AssertExpectations(t)


}

// TestSomethingElse is a second example of how to use our test object to
// make assertions about some target code we are testing.
// This time using a placeholder. Placeholders might be used when the
// data being passed in is normally dynamically generated and cannot be
// predicted beforehand (eg. containing hashes that are time sensitive)
func TestSomethingElse(t *testing.T) {

// create an instance of our test object
testObj := new(MyMockedObject)

// setup expectations with a placeholder in the argument list
testObj.On("DoSomething", mock.Anything).Return(true, nil)

// call the code we are testing
targetFuncThatDoesSomethingWithObj(testObj)

// assert that the expectations were met
testObj.AssertExpectations(t)


}
```

Expand Down

0 comments on commit 380174f

Please sign in to comment.