Skip to main content
Version: 9.x

Collection & Stream Types

Support for Collection Types​

AutoParams offers extensive support for various collection types, enhancing its utility for more complex testing scenarios.

Arrays​

AutoParams automatically generates array instances, each containing three elements by default.

@ParameterizedTest
@AutoSource
void testMethod(int[] array1, String[] array2) {
}

List Types​

Both the List<E> interface and the ArrayList<E> class are supported. AutoParams generates list objects that contain a few elements.

@ParameterizedTest
@AutoSource
void testMethod(List<String> list, ArrayList<UUID> arrayList) {
}

Set Types​

AutoParams also supports the Set<E> interface and the HashSet<E> class, generating set objects that contain a few elements.

@ParameterizedTest
@AutoSource
void testMethod(Set<String> set, HashSet<UUID> hashSet) {
}

Map Interface​

Support extends to the Map<K, V> interface and the HashMap<K, V> class as well. AutoParams generates map objects containing a few key-value pairs.

@ParameterizedTest
@AutoSource
void testMethod(Map<String, ComplexObject> map,
HashMap<UUID, ComplexObject> hashMap) {
}

This comprehensive support for collection types makes AutoParams an exceptionally versatile tool for generating test data, accommodating a wide variety of data structures to ensure thorough testing.

Support for Stream Types​

AutoParams extends its versatility by offering support for various types of stream interfaces, further broadening your testing capabilities.

Generic Stream Interface​

AutoParams supports the generic Stream<T> interface and generates stream objects containing a few elements.

@ParameterizedTest
@AutoSource
void testMethod(Stream<ComplexObject> stream) {
}

Stream Interfaces of Primitive Types​

AutoParams also accommodates stream interfaces that are specific to primitive types, such as IntStream, LongStream, and DoubleStream.

@ParameterizedTest
@AutoSource
void testMethod(IntStream arg1, LongStream arg2, DoubleStream arg3) {
}

This added layer of support for stream types allows AutoParams to be a comprehensive solution for generating test data across a wide range of data structures and types, making your testing more robust and efficient.