how unittest serialization and db access
What is the correct way to write unittests for things like serialization/deserialization or writing and reading objects to/from a repository? Should I test if each and every property of my objects is correctly read and writte开发者_如何学JAVAn? This seems like quite a lot of work when I have lots of types with lots of properties. Is this the way to go?
For serialisation testing, you may want to serialise and compare vs. a canned test (i.e. a pre-serialised object that you know is correct).
So you would have to initially check that your canned serialised object is correct. From that point on, you're performing a regression test by simply comparing a byte stream / string or however your serialised object is represented. It may not tell you easily what has changed, but it will perform the primary function of a regression test and tell you something has changed.
精彩评论