开发者

how unittest serialization and db access

开发者 https://www.devze.com 2022-12-08 05:38 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消