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
Assertion messages could be confusing #1901
Comments
Hi, @Bludator. Thanks for your interest in FakeItEasy. The question about the method name is giving us at FakeItEasy National some small pause, since default interface methods are kind of a special thing (that I don't have a lot of experience with) and we're not entirely sure what output we expect. We'll continue discussing. In the meantime, about
I'm not sure I follow you. In general, the messages are different. Consider the output I get when I omit the
|
I think that the same thing happened without the default method implementation, I guess I forget to remove it, sorry about that. (and I edited the issue)
Well, that is true (if there is no other call on the fake). My point is that in:
It is not clear where the problem is. (The call is there so why it won't pass the test?🤷♀️) Ideally, there should be printed what constraint was not matching and an actual value of the parameter but I don't think it is possible (when the fake has multiple rules, calls, etc.). But something like |
Okay. Confirmed that the default interface implementation was not required to get the output you posted. So the question I see is why we say we failed for
We do print the actual value of the parameter, using ToString. In your sample code, public class Something
{
private readonly int id;
public Something(int id)
{
this.id = id;
}
public override string ToString() => $"Something {id}";
}
[Fact]
public void Test14()
{
var fake = A.Fake<Bar>();
fake.Method(new Something(1));
// asserting different object
A.CallTo(() => fake.Method(new Something(2))).MustHaveHappened();
} yields
|
The printing via |
I'm back with very little information, but in this message
The line that references "Something 2" makes up the reported type name using That's why we're seeing the difference. I'm half thinking that we might be better off with |
Here is the minimal example (body of some class
Test
):Prints:
The method name/defining type should be the same in both cases not
Test+IFoo.Method
andTest+Bar.Method
.Now it looks like there is other problem than the non-mathing parameter as it is the only different thing in the calls as printed.
Also
it would be helpful if the assert message would be different when no calls to a methods were made and when the parameter assertions does not match, becauseit is kind of silly to print something like in the example where the actual parameter looks same as the required one.The text was updated successfully, but these errors were encountered: