Object Theories

Extending the ObjectTheories allows to test the implementation of the equals, hashCode and toString methods.

All that has to be done is to define the data points to test.

@Category(ObjectBasics.class)
@Uut(type = Position.class)
public class PositionObjectTest extends ObjectTheories {
  @DataPoint
  public static final Position POS_1_1 = new Position(1L, 1L);

  @DataPoint
  public static final Position POS_7_1 = new Position(7L, 1L);

  @DataPoint
  public static final Position POS_1_7 = new Position(1L, 7L);

  @DataPoint
  public static final Position POS_7_7 = new Position(7L, 7L);

  @DataPoint
  public static final Position EQUAL = new Position(7L, 7L);

  @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.