Assuming in a unit test I need to have an object all of 50 fields of which are set up with some values. I don't want to manually set up all this fields, as it takes time and annoying...
Somehow I need to get an instance where all the fields are initialized by some not-null values.
and I had an idea - what if I will debug some code, at some point i will get a working instance of this object with some data set up - and I just will serialize it to the disk.
Then I will put this file to test-resources folder, and in unit tests will just deserialize it from that location.
Sounds feasible.. and reasonable? Is there any other idea, or how would you do that?
UPD: I agree serialization is not good in that case. 1) Saved object is not human readable 2) Version could change (highly unlikely) and is not a big problem I believe... So, maybe are there any readable easy-for-serialization formats?
Ideally I would like to have actually source code to be generated. Because it is a java bean, all the getters/setters are there. Why not generate the set of setters calls over the given object in runtime?