Skip to content

Would like more info from Assert-MockCalled failures #376

Open
@msorens

Description

@msorens

A typical failure from Assert-MockCalled is:
"Expected xyz in module abc to be called at least 1 times but was called 0 times"

Working from just that sparse information, though, to find the root cause is quite the challenge! It would be a boon to be able to get some details akin to what the moq framework puts out for an analogous error in .NET code:

Expected invocation on the mock once, but was 0 times: 
    x => x.Execute("foobar", .expectedVersion)
Performed invocations:
    IFrobEnabler.Execute("name604d9152", "f997060d-e3eb")

That is, it reports not just the expected method but the arguments that were expected with it AND what was in fact actually called. In my experience with Assert-MockCalled it is rarely the case that a given method is not called; rather it is not called with what the ParameterFilter was configured for. Thus, in a sense, Pester is telling an untruth when it says "expected xyz to be called but it was not" when it really means that "expected xyz with arguments a & b to be called but it was instead called with a & c".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions