I have following fixture customization:
jFixture.customise()
.useSubType(SuperClass.class, SubClass.class)
.propertyOf(SubClass.class, "string", "foo")
.noResolutionBehaviour().omitSpecimen();
The setString method is only in the SubClass and not in the SuperClass.
Resulting jFixture.create() will result in an object that has auto generated value in the string property and not the overridden value. Debugging inside I found out that it first generates the subtype specimen where the overridden value is correct, but then the superclass auto generation finds the same methods from the specimen (i.e. it will find the setString method) and as there is no override for SuperClass.setString, it will auto generate new string for that property.
I also tested adding .propertyOf(SuperClass.class, "string", "foo"), but that did not help. Probably because the SuperClass does not actually have that method.
I was able to do a workaround for this by adding .add(new OmitAutoPropertyCustomisation(SuperClass.class))
I have following fixture customization: jFixture.customise() .useSubType(SuperClass.class, SubClass.class) .propertyOf(SubClass.class, "string", "foo") .noResolutionBehaviour().omitSpecimen();
The setString method is only in the SubClass and not in the SuperClass.
Resulting jFixture.create() will result in an object that has auto generated value in the string property and not the overridden value. Debugging inside I found out that it first generates the subtype specimen where the overridden value is correct, but then the superclass auto generation finds the same methods from the specimen (i.e. it will find the setString method) and as there is no override for SuperClass.setString, it will auto generate new string for that property.
I also tested adding .propertyOf(SuperClass.class, "string", "foo"), but that did not help. Probably because the SuperClass does not actually have that method.
I was able to do a workaround for this by adding .add(new OmitAutoPropertyCustomisation(SuperClass.class))