java - serialize object for unit testing -
assuming in unit test need have object of 50 fields of set values. don't want manually set fields, takes time , annoying...
somehow need instance fields initialized not-null values.
and had idea - if debug code, @ point working instance of object data set - , serialize disk.
then put file test-resources folder, , in unit tests deserialize location.
sounds feasible.. , reasonable? there other idea, or how that?
upd: agree serialization not in case. 1) saved object not human readable 2) version change (highly unlikely) , not big problem believe... so, maybe there readable easy-for-serialization formats?
ideally have source code generated. because java bean, getters/setters there. why not generate set of setters calls on given object in runtime?
this problem has been solved: https://code.google.com/p/dummycreator/
Comments
Post a Comment