Skip to main content

Generic Types

AutoParams is capable of generating objects of generic types, adhering to its constructor selection policy. When dealing with generic types, AutoParams employs a public constructor with arbitrary arguments for object creation. If multiple public constructors are available, the framework opts for the one with the fewest parameters.

@AllArgsConstructor
@Getter
public class GenericObject<T1, T2> {
private final T1 value1;
private final T2 value2;
}
@ParameterizedTest
@AutoSource
void testMethod(
GenericObject<String, ComplexObject> arg1,
GenericObject<UUID, GenericObject<String, ComplexObject>> arg2) {
}