Recently, I started to use TDD. It's really cool and fun but creating expected object for
assertEquals is very boring and tedious.
At the moment I see only two way for that:
Creating object in code using million of setters. Using that approach greater part of tests is creating expected object. I think it's not very cool.
Writing expected object for example in JSON and then serialize it in test. I can't find disadvantages of that way except possibility of inconsistent state between my beans and test files.
toString() (@Kilian Foth comment)
Some kind of serialization, but I think it deserves attention. Define a strictly controlled toString() and then assert equality with a literal string rather than a second object.
Configuring in DI container(inspired by @Spotted)
I remembered about DI. Does anybody configure expected bean in DI (Spring XML for example) and then inject it to test method? Is it bad and unefficient approach or something normal?
Are there any other techniques/approaches or special tools that can accelerate that process?