Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unit test for backward and forward compatibility?

I am working on developing an Plug-In API that uses Java serialization. The idea is similar to SmallTalk's system images. I was wondering how would to best to automate testing for whether changes I am making will break deserialization since some changes seem to be innocuous like adding a method to an interface that is implemented (as long as that is not called, otherwise it will result in a AbstractMethodException).

Yes, this is more for an experimental spike rather than production code so please do not suggest not using serialisation.

like image 406
Sled Avatar asked Sep 30 '11 17:09

Sled


1 Answers

For backward compatibility of data, keep a lot of old messages in binary form, and see if you can still deserialize them with the new code.

For backward compatibility of code, you'll need some way of building your old code (e.g. one version per release) and testing that against data created from the newest version of the code. This is a slightly more challenging problem - you may want to build a small test jar on each appropriate release, and put that into source control at the same time to avoid having to build the same code again and again. Your tests would then try all the different jar files against the output of the new code.

To be honest, this all sounds like quite a lot of work for an experimental spike. For real work I'd just use protocol buffers of course :)

like image 87
Jon Skeet Avatar answered Oct 28 '22 00:10

Jon Skeet