Extending the SerializationTheory allows to test the serializability of instances of a class that claims to be serializable.
All that has to be done is to define the data points to test.
@Category(ObjectBasics.class) @Uut(type = Position.class) public class PositionSerializableTest extends SerializationTheory { @DataPoint public static final Position POS_1_1 = new Position(1L, 1L); @DataPoint public static final Position POS_MAX_MAX = new Position(Long.MAX_VALUE, Long.MAX_VALUE); }
We use JUnit's @Category annotation to tag the test case class as dealing with object basics. The category class and @Uut annotation are provided by smartics-testdoc-tools. Both annotations are not required for the theory to work and can be omitted.