How to unit test for backward and forward compatibility?

I am working on developing a plug-in API that uses Java serialization. The idea is similar to the images of the SmallTalk system. I was wondering what is the best way to automate testing for whether the changes I create will disrupt deserialization, as some changes seem harmless, for example adding a method to an interface that is implemented (until this is called, otherwise it will result in a AbstractMethodException ) .

Yes, this is more for an experimental burst, not a production code, so please do not suggest using serialization.

+4
source share
1 answer

For backward data compatibility, save many old messages in binary form and see if they can be deserialized with the new code.

For backward code compatibility, you will need some way of creating old code (for example, one version for each version) and testing related to data created from the latest version of the code. This is a slightly more complicated problem: you can create a small test jar in each respective release and at the same time include it in the source control to avoid having to create the same code again and again. Then your tests will try to use all the various jar files to output the new code.

Honestly, all this sounds pretty much for an experimental burst. For real work, I would just use protocol buffers :)

+4
source

All Articles