Skip to content

More type-safe assertions #389

@jesseduffield

Description

@jesseduffield

I went looking for an existing issue for this but couldn't find one.

I would like to have my generated mock include more type-safe assertions. For example if my struct has the following method:

func (obj* MyObj) MyFunc(a int, b int) bool

I currently do the following:

testObj.On("MyFunc", 1, 2).Return(false)

But I would like to do:

testObj.OnMyFunc(1, 2).Return(false)

where OnMyFunc is itself typed to take two arguments exactly, and the object returned has a Return method which requires a bool argument.

This would make it harder to make errors when writing tests, and would alert me to more issues at compile time after I've regenerated my mocks.

The context here is that I'm about to start using this package quite heavily but am wary of how the lack of type safety will make refactoring harder in the future.

Let me know if there's anything I could do to help with this. Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions