six2six / fixture-factory

Generator fake objects from a template
Apache License 2.0
445 stars 88 forks source link

Improve log message when there is no values to fill the constructor #54

Open nykolaslima opened 10 years ago

nykolaslima commented 10 years ago

If I have a User class that does not have a default constructor, Fixture-Factory cannot generate Fixture based on Template Definition.

net.vidageek.mirror.exception.MirrorException: Could not find constructor with args [] on class xpto
    at net.vidageek.mirror.invoke.ConstructorHandlerByArgs.getConstructor(ConstructorHandlerByArgs.java:60)
    at net.vidageek.mirror.invoke.ConstructorHandlerByArgs.withArgs(ConstructorHandlerByArgs.java:37)
    at net.vidageek.mirror.invoke.ConstructorHandlerByArgs.withoutArgs(ConstructorHandlerByArgs.java:33)
    at br.com.six2six.fixturefactory.util.ReflectionUtils.newInstance(ReflectionUtils.java:112)
    at br.com.six2six.fixturefactory.ObjectFactory.createObject(ObjectFactory.java:92)
    at br.com.six2six.fixturefactory.ObjectFactory.gimme(ObjectFactory.java:54)
    at ...
nykolaslima commented 10 years ago

This only happen when we have a constructor that receives parameters with names different from attribute names. Discussing with @ahirata we think that there is no solution to this. But we can improve log message to explain that constructor must have parameters with same atributes names.