Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constructor for mocks #400

Closed
wants to merge 2 commits into from

Conversation

grongor
Copy link
Contributor

@grongor grongor commented Aug 18, 2021

These changes will simplify the tests by not being required to assert mocks expectations every time. This will also eliminate situations where your tests are not failing even though they should, only to find out that you forget the defer statement.

Example
Before:

factory := &mocks.Factory{}
defer factory.AssertExpectations()

something := &mocks.Something{}
defer something.AssertExpectations()

something.On("GetTime").Return("tooLate")

factory.On("Create").Return(something)

testThings(factory)

Now:

factory := mocks.NewFactory()
something := mocks.NewSomething()

something.On("GetTime").Return("tooLate")

factory.On("Create").Return(something)

testThings(factory)

These changes are based on a branch where I did some refactoring, you can see it here #399. If you don't intend to merge the refactoring PR, I can rebase this branch onto the master.

@grongor
Copy link
Contributor Author

grongor commented Sep 13, 2021

Closing this to re-open immediately to run on the new GitHub CI

@grongor grongor closed this Sep 13, 2021
@grongor
Copy link
Contributor Author

grongor commented Sep 13, 2021

New PR here #406

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant