It depends on the complexity of the method. This is really not necessary if the code is trivial, for example:
public interface MyInterface { ObjectProperty<String> ageProperty(); default String getAge() { return ageProperty().getValue(); } }
If the code is more complex, you should write unit test. For example, this is the default method from Comparator :
public interface Comparator<T> { ... default Comparator<T> thenComparing(Comparator<? super T> other) { Objects.requireNonNull(other); return (Comparator<T> & Serializable) (c1, c2) -> { int res = compare(c1, c2); return (res != 0) ? res : other.compare(c1, c2); }; } ... }
How to check it?
Testing a default method from an interface is similar to testing an abstract class.
This has already been answered.
source share