FlexTradeUKLtd / jfixture

JFixture is an open source library based on the popular .NET library, AutoFixture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error message misleading if constructor throws exceptions.

phutchin opened this issue · comments

When constructors throw runtime exceptions, JFixture reports:
"java.lang.UnsupportedOperationException: JFixture was unable to create an instance from com.flextrade.MyClass, most likely because it has no public constructor, is an abstract or non-public type or has no static factory methods"

Hi @phutchin, could you just clarify what you expect to happen here please. I assume you're saying the message should also include the possibility of a constructor failing, or do you have something else in mind?

Thanks!

Yes, I'd like to see a change to the description, saying that the constructor might have thrown an exception.
Actually getting the exception would be good, but I can understand why it's not possible, given that tries many constructors.

OK cool. If you get this situation and you want to know why the constructor failed you just need to add the Tracing Customisation,

fixture.customise(new TracingCustomisation(System.out));

And it'll include any caught exceptions in the output