T
- The type of object to test.public interface CovariantReturnTests<T>
Modifier and Type | Method and Description |
---|---|
default Class<?> |
baseReturnType()
Returns the base return type to test against.
|
default Class<?> |
covariantReturnType()
Returns the covariant return type to test for.
|
default Stream<Method> |
methods()
Returns a stream of methods to test.
|
Class<T> |
objectType()
Returns the type of object to test.
|
default Stream<DynamicContainer> |
testCovariantReturnTypes()
For each method returned by
methods() , test that the method is overridden by objectType() and has
covariantReturnType() as return type. |
Class<T> objectType()
default Class<?> covariantReturnType()
objectType()
.default Class<?> baseReturnType()
covariantReturnType()
.default Stream<Method> methods()
objectType()
that
have baseReturnType()
as return type. Note that this includes static methods; those can be excluded by adding additional filtering:
@Override
public Stream<Method> methods() {
return CovariantReturnTests.super.methods()
.filter(m -> !Modifier.isStatic(m.getModifiers()));
}
@TestFactory @DisplayName(value="covariant return types") default Stream<DynamicContainer> testCovariantReturnTypes()
methods()
, test that the method is overridden by objectType()
and has
covariantReturnType()
as return type.Copyright © 2020–2023. All rights reserved.