Describing a call fails when the ToString() of an argument throws an exception
See original GitHub issueSay we setup a strict fake:
var a = A.Fake<SomeInterface>(s=>s.Strict()); //A strict fake!
var b = A.Fake<SomeOtherInterface>(); //strictness does not matter...
and then we verify the strict fake was passed as an argument to another mock:
//a.ToString() is called for some reason, however a is a strict fake
A.CallTo(()=>b.SomeMethod(a)).MustHaveHappened()
FakeItEasy throws an Exception:
FakeItEasy.ExpectationException : Call to non configured method "ToString" of strict fake.
Call Stack:
at FakeItEasy.FakeOptionsBuilderExtensions.<Strict>b__0<T>(IFakeObjectCall call)
at FakeItEasy.Configuration.BuildableCallRule.Apply(IInterceptedFakeObjectCall fakeObjectCall)
at FakeItEasy.Core.FakeManager.FakeItEasy.Core.IFakeCallProcessor.Process(IWritableFakeObjectCall fakeObjectCall)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.ObjectProxy_4.ToString()
at FakeItEasy.Expressions.ArgumentConstraints.EqualityArgumentConstraint.WriteDescription(IOutputWriter writer)
at FakeItEasy.Expressions.ExpressionCallMatcher.AppendArgumentsListString(StringBuilder result)
at FakeItEasy.Expressions.ExpressionCallMatcher.ToString()
at FakeItEasy.Configuration.BuildableCallRule.WriteDescriptionOfValidCall(IOutputWriter writer)
at FakeItEasy.Configuration.RuleBuilder.MustHaveHappened(Repeated repeatConstraint)
Issue Analytics
- State:
- Created 9 years ago
- Comments:67 (59 by maintainers)
Top Results From Across the Web
What exactly happens when I throw an exception myself ...
And yes, println just calls toString() on all objects. It'll print the stack trace of the exception. – markspace. Oct 27, 2018 at...
Read more >How to Throw Exceptions in Java
In the example below, we have created a test method to demonstrate throwing an exception. The toString() method returns a textual representation ...
Read more >Creating and Throwing Exceptions
Learn about creating and throwing exceptions. Exceptions are used to indicate that an error has occurred while running a program.
Read more >Error.prototype.toString() - JavaScript - MDN Web Docs - Mozilla
The toString() method of Error instances returns a string representing this error.
Read more >AWS Lambda function errors in Java
This page describes how to view Lambda function invocation errors for the Java runtime using the Lambda console and the AWS CLI.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That makes sense.
As mentioned in your PR, I think we should prefix the type name with “Faked” if the value is a fake, since this is the default
ToString()
behavior for fakes.IMO we shouldn’t call
ToString()
at all on a fake, whether it’s strict or not. In my solution we callIFakeObject.ToString()
instead. For non-fakes, I agree that we should catch the exception.