8000 Default expectations and override · Issue #137 · golang/mock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
Default expectations and override #137
Closed
@ybbus

Description

@ybbus

When you do a lot of tests with different dependencies it would be great if you could do the following:

Define a default behaviour (e.g.)

mockA.Expect().Function1().AnyTimes().Return(1)
mockA.Expect().Function2().AnyTimes().Return(2)

mockB.Expect().Function1().AnyTimes().Return(1)
mockB.Expect().Function2().AnyTimes().Return(2)

And most of the time in a single test you want to test a behaviour of your component if one of the default functions return something else (e.g. an error)

Therefore it would be great to override an expectation with a new one (or at least to clear expectations for a function)

So you could define a default behaviour of all functions (e.g. success case) and be able to override single functions that should behave different in specific tests.

Or is there a best practive for this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0