Interface ForEachContract<E,I extends Iterable<E>>
- Type Parameters:
E
- The element type being tested.I
- The iterator type being tested.
- All Superinterfaces:
CollectionContractConfig
,CollectionContractSupport<E,
,I> CollectionProviderSupport<E,
,I> ContractSupport<I>
,ElementProviderSupport<E>
,ProviderSupport<I>
,SupportedMethods
- All Known Subinterfaces:
CollectionContract<E,
,C> IterableContract<E,
,I> ListContract<E,
,L> SequencedCollectionContract<E,
C>
This interface tests if a collection class has implemented the
forEach()
method correctly based upon the
specification provided in Iterable.forEach(Consumer)
.- Since:
- 1.0
- Author:
- evanbergstrom
- See Also:
-
Field Summary
Fields inherited from interface org.soliscode.test.contract.support.CollectionContractSupport
DEFAULT_SIZE
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Tests that theIterable.forEach(java.util.function.Consumer<? super T>)
works for an empty collection.default void
Tests that theIterable.forEach(java.util.function.Consumer<? super T>)
throws the correct exception for anull
action.default void
Tests that theforEach()
works for a collection with elements.Methods inherited from interface org.soliscode.test.contract.CollectionContractConfig
permitDuplicates, permitIncompatibleTypes, permitNulls
Methods inherited from interface org.soliscode.test.contract.support.CollectionProviderSupport
provider
Methods inherited from interface org.soliscode.test.contract.support.ElementProviderSupport
elementProvider
Methods inherited from interface org.soliscode.test.SupportedMethods
supportsMethod
-
Method Details
-
testForEachForEmptyCollection
@Test @DisplayName("ForEach does not call the action for an iterable with no elements") default void testForEachForEmptyCollection()Tests that theIterable.forEach(java.util.function.Consumer<? super T>)
works for an empty collection. -
testForeEachOverCollectionWithElements
@Test @DisplayName("ForEach calls the action each element in an iterable") default void testForeEachOverCollectionWithElements()Tests that theforEach()
works for a collection with elements. -
testForEachWithNullAction
@Test @DisplayName("ForEach throws a NullPointerException when called with a null action") default void testForEachWithNullAction()Tests that theIterable.forEach(java.util.function.Consumer<? super T>)
throws the correct exception for anull
action.
-