Skip to content

Commit

Permalink
Update features.md
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp authored Feb 21, 2023
1 parent 6397125 commit 757027c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
Features
========

Mock Constructors
-----------------

All mock objects have constructor functions. These constructors do basic test setup so that the expectations you set in the code are asserted before the test exist.

Previously something like this would need to be done:
```go
factory := &mocks.Factory{}
factory.Test(t) // so that mock does not panic when a method is unexpected
defer factory.AssertExpectations(t)
```

Instead, you may simply use the constructor:
```go
factory := mocks.NewFactory(t)
```

The constructor sets up common functionalities automatically
- The `AssertExpectations` method is registered to be called at the end of the tests via `t.Cleanup()` method.
- The testing.TB interface is registered on the `mock.Mock` so that tests don't panic when a call on the mock is unexpected.


Expecter Structs
----------------

Expand Down

0 comments on commit 757027c

Please sign in to comment.