Menu

Checkers

Romain Delamare

Checkers

Checkers perform automatic dynamic verifications. There are two kinds of of checkers: class checkers and method checkers. Class checkers extend ClassChecker and are run a class. They usually perform verifications on specific methods in a class, such as toString. Method checkers extend MethodChecker and are run on each method.

The IEasycoverageChecker interface has two methods, check and shouldCheck. check performs the verification, while shouldCheck returns true if the checker is applicable on the current class or method. shouldCheck is used to avoid unnecessary calls to check.

Implemented checkers

Class checkers

  • BijectiveCompareToChecker
    Checkers that verifies that for any class implementing Comparable, o1.compareTo(o2) is always -o2.compareTo(o1).
  • BijectiveEqualsChecker
    Checkers that verifies that, for any class implementing equals, o1.equals(o2) returns the same result as o2.equals(o1).
  • CloneChecker
    Checkers that verifies that, for each class implementing Cloneable, that o.equals(o.clone).
  • NPEConstructorChecker
    Checkers that verifies, for every controllers of a class, that they do not have a null pointer exception.
  • NullValueEqualsChecker
    Checkers that verifies that o.equals(null) always return false.
  • ToStringNotNullChecker
    Checkers that vefiries that toString does not return null, for each class that implements it.

Method checkers

  • ArrayIndexOutOfBoundExceptionChecker
    Checkers that verifies that no array index out of bound are thrown. It will try to invoke each method with min and max values.
  • GetterNotNullChecker
    Checkers that checks a getter does not return null.
  • NPEMethodChecker
    Checkers that verifies that a method does not throw a null pointer exception.
  • SetterChecker
    Checkers that verifies, for a getter/setter pair, that the value return by the getter is the value previously set.

Writing a checker

To write a checker, you need to extend ClassChecker or MethodChecker, depending on the kind of checker you want to create. These are abstract classes, so you need to implement check. This method should throw an EasycoverageAssertionFailedError if the check fails. Class checkers (respectively method checkers) also need to implement shouldCheckClass (respectively shouldCheckMethod).


Related

Wiki: Home
Wiki: Quick Start