Class Verify
- java.lang.Object
-
- org.junit.Assert
-
- org.eclipse.collections.impl.test.Verify
-
public final class Verify extends org.junit.AssertAn extension of theAssertclass, which adds useful additional "assert" methods. You can import this class instead of Assert, and use it thus, e.g.:Verify.assertEquals("fred", name); // from original Assert class Verify.assertContains("fred", nameList); // from new extensions Verify.assertBefore("fred", "jim", orderedNamesList); // from new extensions
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> voidassertAllSatisfy(Iterable<T> iterable, Predicate<? super T> predicate)static <T> voidassertAllSatisfy(String message, Iterable<T> iterable, Predicate<? super T> predicate)static <K,V>
voidassertAllSatisfy(Map<K,V> map, Predicate<? super V> predicate)static <T> voidassertAnySatisfy(Iterable<T> iterable, Predicate<? super T> predicate)static <T> voidassertAnySatisfy(String message, Iterable<T> iterable, Predicate<? super T> predicate)static <K,V>
voidassertAnySatisfy(Map<K,V> map, Predicate<? super V> predicate)static <K,V>
voidassertBagMultimapsEqual(String multimapName, BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)static <K,V>
voidassertBagMultimapsEqual(BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)static voidassertBagsEqual(String bagName, Bag<?> expectedBag, Bag<?> actualBag)static voidassertBagsEqual(Bag<?> expectedBag, Bag<?> actualBag)static voidassertBefore(Object formerItem, Object latterItem, List<?> actualList)Assert that the formerItem appears before the latterItem in the givenCollection.static voidassertBefore(String listName, Object formerItem, Object latterItem, List<?> actualList)Assert that the formerItem appears before the latterItem in the givenCollection.static <T> voidassertClassNonInstantiable(Class<T> aClass)static voidassertContains(Object expectedItem, Collection<?> actualCollection)Assert that the givenCollectioncontains the given item.static voidassertContains(Object expectedItem, ImmutableCollection<?> actualImmutableCollection)Assert that the givenImmutableCollectioncontains the given item.static voidassertContains(String collectionName, Object expectedItem, Collection<?> actualCollection)Assert that the givenCollectioncontains the given item.static voidassertContains(String immutableCollectionName, Object expectedItem, ImmutableCollection<?> actualImmutableCollection)Assert that the givenImmutableCollectioncontains the given item.static voidassertContains(String stringToFind, String stringToSearch)Assert that the givenstringToFindis contained within thestringToSearch.static voidassertContains(String stringName, String stringToFind, String stringToSearch)Assert that the givenstringToFindis contained within thestringToSearch.static voidassertContainsAll(Iterable<?> iterable, Object... items)static voidassertContainsAll(String collectionName, Iterable<?> iterable, Object... items)static voidassertContainsAllEntries(String multimapName, Multimap<?,?> actualMultimap, Object... expectedKeyValues)Assert the givenMultimapcontains all the given keys and values.static voidassertContainsAllEntries(Multimap<?,?> actualMultimap, Object... keyValues)Assert the givenMultimapcontains all the given keys and values.static voidassertContainsAllKeyValues(String mapName, Map<?,?> actualMap, Object... expectedKeyValues)Assert that the givenMapcontains all the given keys and values.static voidassertContainsAllKeyValues(String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, Object... expectedKeyValues)Assert that the givenImmutableMapIterablecontains all the given keys and values.static voidassertContainsAllKeyValues(String mapIterableName, MapIterable<?,?> mapIterable, Object... expectedKeyValues)Assert that the givenMapIterablecontains all the given keys and values.static voidassertContainsAllKeyValues(String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, Object... expectedKeyValues)Assert that the givenMutableMapIterablecontains all the given keys and values.static voidassertContainsAllKeyValues(Map<?,?> actualMap, Object... keyValues)Assert that the givenMapcontains all the given keys and values.static voidassertContainsAllKeyValues(ImmutableMapIterable<?,?> immutableMapIterable, Object... keyValues)Assert that the givenImmutableMapIterablecontains all the given keys and values.static voidassertContainsAllKeyValues(MapIterable<?,?> mapIterable, Object... keyValues)Assert that the givenMapIterablecontains all the given keys and values.static voidassertContainsAllKeyValues(MutableMapIterable<?,?> mutableMapIterable, Object... keyValues)Assert that the givenMutableMapIterablecontains all the given keys and values.static <K,V>
voidassertContainsEntry(String multimapName, K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)Assert that the givenMultimapcontains an entry with the given key and value.static <K,V>
voidassertContainsEntry(K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)Assert that the givenMultimapcontains an entry with the given key and value.static voidassertContainsKey(Object expectedKey, Map<?,?> actualMap)Assert that the givenMapcontains an entry with the given key.static voidassertContainsKey(Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)Assert that the givenImmutableMapIterablecontains an entry with the given key.static voidassertContainsKey(Object expectedKey, MapIterable<?,?> mapIterable)Assert that the givenMapIterablecontains an entry with the given key.static voidassertContainsKey(Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)Assert that the givenMutableMapIterablecontains an entry with the given key.static voidassertContainsKey(String mapName, Object expectedKey, Map<?,?> actualMap)Assert that the givenMapcontains an entry with the given key.static voidassertContainsKey(String immutableMapIterableName, Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)Assert that the givenImmutableMapIterablecontains an entry with the given key.static voidassertContainsKey(String mapIterableName, Object expectedKey, MapIterable<?,?> mapIterable)Assert that the givenMapIterablecontains an entry with the given key.static voidassertContainsKey(String mutableMapIterableName, Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)Assert that the givenMutableMapIterablecontains an entry with the given key.static voidassertContainsKeyValue(Object expectedKey, Object expectedValue, Map<?,?> actualMap)Assert that the givenMapcontains an entry with the given key and value.static voidassertContainsKeyValue(Object expectedKey, Object expectedValue, ImmutableMapIterable<?,?> mapIterable)Assert that the givenImmutableMapIterablecontains an entry with the given key and value.static voidassertContainsKeyValue(Object expectedKey, Object expectedValue, MapIterable<?,?> mapIterable)Assert that the givenMapIterablecontains an entry with the given key and value.static voidassertContainsKeyValue(Object expectedKey, Object expectedValue, MutableMapIterable<?,?> mapIterable)Assert that the givenMutableMapIterablecontains an entry with the given key and value.static voidassertContainsKeyValue(String mapName, Object expectedKey, Object expectedValue, Map<?,?> actualMap)Assert that the givenMapcontains an entry with the given key and value.static voidassertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, ImmutableMapIterable<?,?> immutableMapIterable)Assert that the givenImmutableMapIterablecontains an entry with the given key and value.static voidassertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, MapIterable<?,?> mapIterable)Assert that the givenMapIterablecontains an entry with the given key and value.static voidassertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, MutableMapIterable<?,?> mutableMapIterable)Assert that the givenMutableMapIterablecontains an entry with the given key and value.static voidassertContainsNone(Collection<?> actualCollection, Object... items)static <T> voidassertCount(int expectedCount, Iterable<T> iterable, Predicate<? super T> predicate)static voidassertDeserializedForm(String expectedBase64Form, Object actualObject)static voidassertEmpty(Iterable<?> actualIterable)Assert that the givenIterableis empty.static voidassertEmpty(String iterableName, Iterable<?> actualIterable)Assert that the givenCollectionis empty.static voidassertEmpty(String mapName, Map<?,?> actualMap)Assert that the givenMapis empty.static voidassertEmpty(String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)Assert that the givenCollectionis empty.static voidassertEmpty(String multimapName, Multimap<?,?> actualMultimap)Assert that the givenMultimapis empty.static voidassertEmpty(String iterableName, PrimitiveIterable primitiveIterable)Assert that the givenPrimitiveIterableis empty.static voidassertEmpty(Map<?,?> actualMap)Assert that the givenMapis empty.static voidassertEmpty(MutableMapIterable<?,?> actualMutableMapIterable)Assert that the givenMutableMapIterableis empty.static voidassertEmpty(Multimap<?,?> actualMultimap)Assert that the givenMultimapis empty.static voidassertEmpty(PrimitiveIterable primitiveIterable)Assert that the givenPrimitiveIterableis empty.static <T> voidassertEndsWith(List<T> list, T... items)static <T> voidassertEndsWith(T[] array, T... items)static voidassertEqualsAndHashCode(Object objectA, Object objectB)Assert thatobjectAandobjectBare equal via theObject.equals(Object)method, and that they both return the sameObject.hashCode().static voidassertEqualsAndHashCode(String itemNames, Object objectA, Object objectB)Assert thatobjectAandobjectBare equal (via theObject.equals(Object)method, and that they both return the sameObject.hashCode().static voidassertError(Class<? extends Error> expectedErrorClass, Runnable code)static voidassertInstanceOf(Class<?> expectedClassType, Object actualObject)Assert that the given object is an instanceof expectedClassType.static voidassertInstanceOf(String objectName, Class<?> expectedClassType, Object actualObject)Assert that the given object is an instanceof expectedClassType.static voidassertItemAtIndex(Object expectedItem, int index, Object[] array)Assert that the givenitemis at theindexin the givenarray.static voidassertItemAtIndex(Object expectedItem, int index, List<?> list)static voidassertItemAtIndex(String arrayName, Object expectedItem, int index, Object[] array)static voidassertItemAtIndex(String listName, Object expectedItem, int index, List<?> list)static voidassertIterableEmpty(Iterable<?> iterable)Assert that the givenIterableis empty.static voidassertIterableEmpty(String iterableName, Iterable<?> iterable)Assert that the givenIterableis empty.static voidassertIterableNotEmpty(Iterable<?> iterable)Assert that the givenIterableis not empty.static voidassertIterableNotEmpty(String iterableName, Iterable<?> iterable)Assert that the givenIterableis not empty.static voidassertIterablesEqual(Iterable<?> expectedIterable, Iterable<?> actualIterable)static voidassertIterablesEqual(String iterableName, Iterable<?> expectedIterable, Iterable<?> actualIterable)static voidassertIterableSize(int expectedSize, Iterable<?> actualIterable)Assert the size of the givenIterable.static voidassertIterableSize(String iterableName, int expectedSize, Iterable<?> actualIterable)Assert the size of the givenIterable.static <K,V>
voidassertListMultimapsEqual(String multimapName, ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)static <K,V>
voidassertListMultimapsEqual(ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)static voidassertListsEqual(String listName, List<?> expectedList, List<?> actualList)static voidassertListsEqual(List<?> expectedList, List<?> actualList)static voidassertMapsEqual(String mapName, Map<?,?> expectedMap, Map<?,?> actualMap)static voidassertMapsEqual(Map<?,?> expectedMap, Map<?,?> actualMap)static voidassertNegative(int value)Asserts that a value is negative.static <T> voidassertNoneSatisfy(Iterable<T> iterable, Predicate<? super T> predicate)static <T> voidassertNoneSatisfy(String message, Iterable<T> iterable, Predicate<? super T> predicate)static <K,V>
voidassertNoneSatisfy(Map<K,V> map, Predicate<? super V> predicate)static voidassertNotContains(Object unexpectedItem, Iterable<?> iterable)Assert that the givenIterabledoes not contain the given item.static voidassertNotContains(Object unexpectedItem, Collection<?> actualCollection)Assert that the givenCollectiondoes not contain the given item.static voidassertNotContains(String collectionName, Object unexpectedItem, Iterable<?> iterable)Assert that the givenIterabledoes not contain the given item.static voidassertNotContains(String collectionName, Object unexpectedItem, Collection<?> actualCollection)Assert that the givenCollectiondoes not contain the given item.static voidassertNotContains(String unexpectedString, String stringToSearch)Assert that the givenunexpectedStringis not contained within thestringToSearch.static voidassertNotContains(String stringName, String unexpectedString, String stringToSearch)Assert that the givenunexpectedStringis not contained within thestringToSearch.static voidassertNotContainsKey(Object unexpectedKey, Map<?,?> actualMap)Assert that the givenCollectiondoes not contain the given item.static voidassertNotContainsKey(String mapName, Object unexpectedKey, Map<?,?> actualMap)Assert that the givenCollectiondoes not contain the given item.static voidassertNotEmpty(Iterable<?> actualIterable)Assert that the givenIterableis not empty.static voidassertNotEmpty(String iterableName, Iterable<?> actualIterable)Assert that the givenIterableis not empty.static voidassertNotEmpty(String mapName, Map<?,?> actualMap)Assert that the givenMapis not empty.static voidassertNotEmpty(String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)Assert that the givenMutableMapIterableis not empty.static voidassertNotEmpty(String multimapName, Multimap<?,?> actualMultimap)Assert that the givenMultimapis not empty.static voidassertNotEmpty(String iterableName, PrimitiveIterable primitiveIterable)Assert that the givenPrimitiveIterableis not empty.static <T> voidassertNotEmpty(String itemsName, T[] items)static voidassertNotEmpty(Map<?,?> actualMap)Assert that the givenMapis not empty.static voidassertNotEmpty(MutableMapIterable<?,?> actualMutableMapIterable)Assert that the givenMutableMapIterableis not empty.static voidassertNotEmpty(Multimap<?,?> actualMultimap)Assert that the givenMultimapis not empty.static voidassertNotEmpty(PrimitiveIterable primitiveIterable)Assert that the givenPrimitiveIterableis not empty.static <T> voidassertNotEmpty(T[] items)static voidassertNotInstanceOf(Class<?> expectedClassType, Object actualObject)Assert that the given object is not an instanceof expectedClassType.static voidassertNotInstanceOf(String objectName, Class<?> expectedClassType, Object actualObject)Assert that the given object is not an instanceof expectedClassType.static voidassertNotSerializable(Object actualObject)static voidassertObjectNotNull(String objectName, Object actualObject)static voidassertPositive(int value)Asserts that a value is positive.static voidassertPostSerializedEqualsAndHashCode(Object object)static voidassertPostSerializedEqualsHashCodeAndToString(Object object)static voidassertPostSerializedIdentity(Object object)static voidassertSerializedForm(long expectedSerialVersionUID, String expectedBase64Form, Object actualObject)static voidassertSerializedForm(String expectedBase64Form, Object actualObject)static <K,V>
voidassertSetMultimapsEqual(String multimapName, SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)static <K,V>
voidassertSetMultimapsEqual(SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)static voidassertSetsEqual(String setName, Set<?> expectedSet, Set<?> actualSet)static voidassertSetsEqual(Set<?> expectedSet, Set<?> actualSet)static voidassertShallowClone(Cloneable object)Deprecated.since 8.2.0 as will not work with Java 9static voidassertShallowClone(String itemName, Cloneable object)Deprecated.since 8.2.0 as will not work with Java 9static voidassertSize(int expectedSize, Iterable<?> actualIterable)Assert the size of the givenIterable.static voidassertSize(int expectedSize, Object[] actualArray)Assert the size of the given array.static voidassertSize(int expectedSize, Map<?,?> actualMap)Assert the size of the givenMap.static voidassertSize(int expectedSize, MutableMapIterable<?,?> mutableMapIterable)Assert the size of the givenMutableMapIterable.static voidassertSize(int expectedSize, Multimap<?,?> actualMultimap)Assert the size of the givenMultimap.static voidassertSize(int expectedSize, PrimitiveIterable primitiveIterable)Assert the size of the givenPrimitiveIterable.static voidassertSize(int expectedSize, ImmutableSet<?> actualImmutableSet)Assert the size of the givenImmutableSet.static voidassertSize(String iterableName, int expectedSize, Iterable<?> actualIterable)Assert the size of the givenIterable.static voidassertSize(String arrayName, int expectedSize, Object[] actualArray)Assert the size of the given array.static voidassertSize(String mapName, int expectedSize, Map<?,?> actualMap)Assert the size of the givenMap.static voidassertSize(String mapName, int expectedSize, MutableMapIterable<?,?> mutableMapIterable)Assert the size of the givenMutableMapIterable.static voidassertSize(String multimapName, int expectedSize, Multimap<?,?> actualMultimap)Assert the size of the givenMultimap.static voidassertSize(String primitiveIterableName, int expectedSize, PrimitiveIterable actualPrimitiveIterable)Assert the size of the givenPrimitiveIterable.static voidassertSize(String immutableSetName, int expectedSize, ImmutableSet<?> actualImmutableSet)Assert the size of the givenImmutableSet.static <K,V>
voidassertSortedBagMultimapsEqual(String multimapName, SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)static <K,V>
voidassertSortedBagMultimapsEqual(SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)static voidassertSortedBagsEqual(String bagName, SortedBag<?> expectedBag, SortedBag<?> actualBag)static voidassertSortedBagsEqual(SortedBag<?> expectedBag, SortedBag<?> actualBag)static voidassertSortedMapsEqual(String mapName, SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)static voidassertSortedMapsEqual(SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)static <K,V>
voidassertSortedSetMultimapsEqual(String multimapName, SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)static <K,V>
voidassertSortedSetMultimapsEqual(SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)static voidassertSortedSetsEqual(String setName, SortedSet<?> expectedSet, SortedSet<?> actualSet)static voidassertSortedSetsEqual(SortedSet<?> expectedSet, SortedSet<?> actualSet)static <T> voidassertStartsWith(String listName, List<T> list, T... items)static <T> voidassertStartsWith(List<T> list, T... items)static <T> voidassertStartsWith(T[] array, T... items)static voidassertThrows(Class<? extends Exception> expectedExceptionClass, Callable<?> code)static voidassertThrowsWithCause(Class<? extends Exception> expectedExceptionClass, Class<? extends Throwable> expectedCauseClass, Runnable code)Runs theRunnablecodeand asserts that it throws anExceptionof the typeexpectedExceptionClass, which contains a cause of type expectedCauseClass.static voidassertThrowsWithCause(Class<? extends Exception> expectedExceptionClass, Class<? extends Throwable> expectedCauseClass, Callable<?> code)Runs theCallablecodeand asserts that it throws anExceptionof the typeexpectedExceptionClass, which contains a cause of type expectedCauseClass.static voidassertZero(int value)Asserts that a value is positive.static voiddenyContainsAny(String collectionName, Collection<?> actualCollection, Object... items)static voiddenyContainsAny(Collection<?> actualCollection, Object... items)static voiddenyContainsKey(Object unexpectedKey, Map<?,?> actualMap)Deny that the givenMapcontains an entry with the given key.static voiddenyContainsKey(String mapName, Object unexpectedKey, Map<?,?> actualMap)Deny that the givenMapcontains an entry with the given key.static voidfail(String message, Throwable cause)static voidthrowMangledException(AssertionError e)Mangles the stack trace ofAssertionErrorso that it looks like it's been thrown from the line that called to a custom assertion.static voidthrowMangledException(AssertionError e, int framesToPop)Mangles the stack trace ofAssertionErrorso that it looks like it's been thrown from the line that called to a custom assertion.-
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail
-
-
-
-
Method Detail
-
throwMangledException
public static void throwMangledException(AssertionError e)
Mangles the stack trace ofAssertionErrorso that it looks like it's been thrown from the line that called to a custom assertion.This method behaves identically to
throwMangledException(AssertionError, int)and is provided for convenience for assert methods that only want to pop two stack frames. The only time that you would want to call the otherthrowMangledException(AssertionError, int)method is if you have a custom assert that calls another custom assert i.e. the source line calling the custom asserts is more than two stack frames away- Parameters:
e- The exception to mangle.- See Also:
throwMangledException(AssertionError, int)
-
throwMangledException
public static void throwMangledException(AssertionError e, int framesToPop)
Mangles the stack trace ofAssertionErrorso that it looks like it's been thrown from the line that called to a custom assertion.This is useful for when you are in a debugging session, and you want to go to the source of the problem in the test case quickly. The regular use case for this would be something along the lines of:
public class TestFoo extends junit.framework.TestCase { public void testFoo() throws Exception { Foo foo = new Foo(); ... assertFoo(foo); } // Custom assert private static void assertFoo(Foo foo) { try { assertEquals(...); ... assertSame(...); } catch (AssertionFailedException e) { AssertUtils.throwMangledException(e, 2); } } }Without the
try ... catchblock around lines 11-13 the stack trace following a test failure would look a little like:java.lang.AssertionError: ... at TestFoo.assertFoo(TestFoo.java:11) at TestFoo.testFoo(TestFoo.java:5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) ...
Note that the source of the error isn't readily apparent as the first line in the stack trace is the code within the custom assert. If we were debugging the failure we would be more interested in the second line of the stack trace which shows us where in our tests the assert failed.
With the
try ... catchblock around lines 11-13 the stack trace would look like the following:java.lang.AssertionError: ... at TestFoo.testFoo(TestFoo.java:5) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) ...
Here the source of the error is more visible as we can instantly see that the testFoo test is failing at line 5.
- Parameters:
e- The exception to mangle.framesToPop- The number of frames to remove from the stack trace.- Throws:
AssertionError- that was given as an argument with its stack trace mangled.
-
assertEmpty
public static void assertEmpty(Iterable<?> actualIterable)
Assert that the givenIterableis empty.
-
assertEmpty
public static void assertEmpty(String iterableName, Iterable<?> actualIterable)
Assert that the givenCollectionis empty.
-
assertEmpty
public static void assertEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterableis empty.
-
assertEmpty
public static void assertEmpty(String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenCollectionis empty.
-
assertEmpty
public static void assertEmpty(PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterableis empty.
-
assertEmpty
public static void assertEmpty(String iterableName, PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterableis empty.
-
assertIterableEmpty
public static void assertIterableEmpty(Iterable<?> iterable)
Assert that the givenIterableis empty.
-
assertIterableEmpty
public static void assertIterableEmpty(String iterableName, Iterable<?> iterable)
Assert that the givenIterableis empty.
-
assertInstanceOf
public static void assertInstanceOf(Class<?> expectedClassType, Object actualObject)
Assert that the given object is an instanceof expectedClassType.
-
assertInstanceOf
public static void assertInstanceOf(String objectName, Class<?> expectedClassType, Object actualObject)
Assert that the given object is an instanceof expectedClassType.
-
assertNotInstanceOf
public static void assertNotInstanceOf(Class<?> expectedClassType, Object actualObject)
Assert that the given object is not an instanceof expectedClassType.
-
assertNotInstanceOf
public static void assertNotInstanceOf(String objectName, Class<?> expectedClassType, Object actualObject)
Assert that the given object is not an instanceof expectedClassType.
-
assertEmpty
public static void assertEmpty(Map<?,?> actualMap)
Assert that the givenMapis empty.
-
assertEmpty
public static void assertEmpty(Multimap<?,?> actualMultimap)
Assert that the givenMultimapis empty.
-
assertEmpty
public static void assertEmpty(String multimapName, Multimap<?,?> actualMultimap)
Assert that the givenMultimapis empty.
-
assertEmpty
public static void assertEmpty(String mapName, Map<?,?> actualMap)
Assert that the givenMapis empty.
-
assertNotEmpty
public static void assertNotEmpty(Iterable<?> actualIterable)
Assert that the givenIterableis not empty.
-
assertNotEmpty
public static void assertNotEmpty(String iterableName, Iterable<?> actualIterable)
Assert that the givenIterableis not empty.
-
assertNotEmpty
public static void assertNotEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterableis not empty.
-
assertNotEmpty
public static void assertNotEmpty(String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
Assert that the givenMutableMapIterableis not empty.
-
assertNotEmpty
public static void assertNotEmpty(PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterableis not empty.
-
assertNotEmpty
public static void assertNotEmpty(String iterableName, PrimitiveIterable primitiveIterable)
Assert that the givenPrimitiveIterableis not empty.
-
assertIterableNotEmpty
public static void assertIterableNotEmpty(Iterable<?> iterable)
Assert that the givenIterableis not empty.
-
assertIterableNotEmpty
public static void assertIterableNotEmpty(String iterableName, Iterable<?> iterable)
Assert that the givenIterableis not empty.
-
assertNotEmpty
public static void assertNotEmpty(Map<?,?> actualMap)
Assert that the givenMapis not empty.
-
assertNotEmpty
public static void assertNotEmpty(String mapName, Map<?,?> actualMap)
Assert that the givenMapis not empty.
-
assertNotEmpty
public static void assertNotEmpty(Multimap<?,?> actualMultimap)
Assert that the givenMultimapis not empty.
-
assertNotEmpty
public static void assertNotEmpty(String multimapName, Multimap<?,?> actualMultimap)
Assert that the givenMultimapis not empty.
-
assertNotEmpty
public static <T> void assertNotEmpty(String itemsName, T[] items)
-
assertNotEmpty
public static <T> void assertNotEmpty(T[] items)
-
assertSize
public static void assertSize(int expectedSize, Object[] actualArray)Assert the size of the given array.
-
assertSize
public static void assertSize(String arrayName, int expectedSize, Object[] actualArray)
Assert the size of the given array.
-
assertSize
public static void assertSize(int expectedSize, Iterable<?> actualIterable)Assert the size of the givenIterable.
-
assertSize
public static void assertSize(String iterableName, int expectedSize, Iterable<?> actualIterable)
Assert the size of the givenIterable.
-
assertSize
public static void assertSize(int expectedSize, PrimitiveIterable primitiveIterable)Assert the size of the givenPrimitiveIterable.
-
assertSize
public static void assertSize(String primitiveIterableName, int expectedSize, PrimitiveIterable actualPrimitiveIterable)
Assert the size of the givenPrimitiveIterable.
-
assertIterableSize
public static void assertIterableSize(int expectedSize, Iterable<?> actualIterable)Assert the size of the givenIterable.
-
assertIterableSize
public static void assertIterableSize(String iterableName, int expectedSize, Iterable<?> actualIterable)
Assert the size of the givenIterable.
-
assertSize
public static void assertSize(String mapName, int expectedSize, Map<?,?> actualMap)
Assert the size of the givenMap.
-
assertSize
public static void assertSize(int expectedSize, Map<?,?> actualMap)Assert the size of the givenMap.
-
assertSize
public static void assertSize(int expectedSize, Multimap<?,?> actualMultimap)Assert the size of the givenMultimap.
-
assertSize
public static void assertSize(String multimapName, int expectedSize, Multimap<?,?> actualMultimap)
Assert the size of the givenMultimap.
-
assertSize
public static void assertSize(int expectedSize, MutableMapIterable<?,?> mutableMapIterable)Assert the size of the givenMutableMapIterable.
-
assertSize
public static void assertSize(String mapName, int expectedSize, MutableMapIterable<?,?> mutableMapIterable)
Assert the size of the givenMutableMapIterable.
-
assertSize
public static void assertSize(int expectedSize, ImmutableSet<?> actualImmutableSet)Assert the size of the givenImmutableSet.
-
assertSize
public static void assertSize(String immutableSetName, int expectedSize, ImmutableSet<?> actualImmutableSet)
Assert the size of the givenImmutableSet.
-
assertContains
public static void assertContains(String stringToFind, String stringToSearch)
Assert that the givenstringToFindis contained within thestringToSearch.
-
assertNotContains
public static void assertNotContains(String unexpectedString, String stringToSearch)
Assert that the givenunexpectedStringis not contained within thestringToSearch.
-
assertContains
public static void assertContains(String stringName, String stringToFind, String stringToSearch)
Assert that the givenstringToFindis contained within thestringToSearch.
-
assertNotContains
public static void assertNotContains(String stringName, String unexpectedString, String stringToSearch)
Assert that the givenunexpectedStringis not contained within thestringToSearch.
-
assertCount
public static <T> void assertCount(int expectedCount, Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAllSatisfy
public static <T> void assertAllSatisfy(Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAllSatisfy
public static <K,V> void assertAllSatisfy(Map<K,V> map, Predicate<? super V> predicate)
-
assertAllSatisfy
public static <T> void assertAllSatisfy(String message, Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAnySatisfy
public static <T> void assertAnySatisfy(Iterable<T> iterable, Predicate<? super T> predicate)
-
assertAnySatisfy
public static <K,V> void assertAnySatisfy(Map<K,V> map, Predicate<? super V> predicate)
-
assertAnySatisfy
public static <T> void assertAnySatisfy(String message, Iterable<T> iterable, Predicate<? super T> predicate)
-
assertNoneSatisfy
public static <T> void assertNoneSatisfy(Iterable<T> iterable, Predicate<? super T> predicate)
-
assertNoneSatisfy
public static <K,V> void assertNoneSatisfy(Map<K,V> map, Predicate<? super V> predicate)
-
assertNoneSatisfy
public static <T> void assertNoneSatisfy(String message, Iterable<T> iterable, Predicate<? super T> predicate)
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(Map<?,?> actualMap, Object... keyValues)
Assert that the givenMapcontains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(String mapName, Map<?,?> actualMap, Object... expectedKeyValues)
Assert that the givenMapcontains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(MapIterable<?,?> mapIterable, Object... keyValues)
Assert that the givenMapIterablecontains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(String mapIterableName, MapIterable<?,?> mapIterable, Object... expectedKeyValues)
Assert that the givenMapIterablecontains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(MutableMapIterable<?,?> mutableMapIterable, Object... keyValues)
Assert that the givenMutableMapIterablecontains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, Object... expectedKeyValues)
Assert that the givenMutableMapIterablecontains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(ImmutableMapIterable<?,?> immutableMapIterable, Object... keyValues)
Assert that the givenImmutableMapIterablecontains all the given keys and values.
-
assertContainsAllKeyValues
public static void assertContainsAllKeyValues(String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, Object... expectedKeyValues)
Assert that the givenImmutableMapIterablecontains all the given keys and values.
-
denyContainsAny
public static void denyContainsAny(Collection<?> actualCollection, Object... items)
-
assertContainsNone
public static void assertContainsNone(Collection<?> actualCollection, Object... items)
-
assertContains
public static void assertContains(Object expectedItem, Collection<?> actualCollection)
Assert that the givenCollectioncontains the given item.
-
assertContains
public static void assertContains(String collectionName, Object expectedItem, Collection<?> actualCollection)
Assert that the givenCollectioncontains the given item.
-
assertContains
public static void assertContains(Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
Assert that the givenImmutableCollectioncontains the given item.
-
assertContains
public static void assertContains(String immutableCollectionName, Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
Assert that the givenImmutableCollectioncontains the given item.
-
assertContainsAll
public static void assertContainsAll(String collectionName, Iterable<?> iterable, Object... items)
-
assertListsEqual
public static void assertListsEqual(String listName, List<?> expectedList, List<?> actualList)
-
assertSetsEqual
public static void assertSetsEqual(String setName, Set<?> expectedSet, Set<?> actualSet)
-
assertSortedSetsEqual
public static void assertSortedSetsEqual(SortedSet<?> expectedSet, SortedSet<?> actualSet)
-
assertSortedSetsEqual
public static void assertSortedSetsEqual(String setName, SortedSet<?> expectedSet, SortedSet<?> actualSet)
-
assertSortedBagsEqual
public static void assertSortedBagsEqual(SortedBag<?> expectedBag, SortedBag<?> actualBag)
-
assertSortedBagsEqual
public static void assertSortedBagsEqual(String bagName, SortedBag<?> expectedBag, SortedBag<?> actualBag)
-
assertSortedMapsEqual
public static void assertSortedMapsEqual(SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)
-
assertSortedMapsEqual
public static void assertSortedMapsEqual(String mapName, SortedMapIterable<?,?> expectedMap, SortedMapIterable<?,?> actualMap)
-
assertIterablesEqual
public static void assertIterablesEqual(Iterable<?> expectedIterable, Iterable<?> actualIterable)
-
assertIterablesEqual
public static void assertIterablesEqual(String iterableName, Iterable<?> expectedIterable, Iterable<?> actualIterable)
-
assertMapsEqual
public static void assertMapsEqual(String mapName, Map<?,?> expectedMap, Map<?,?> actualMap)
-
assertBagsEqual
public static void assertBagsEqual(String bagName, Bag<?> expectedBag, Bag<?> actualBag)
-
assertListMultimapsEqual
public static <K,V> void assertListMultimapsEqual(ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)
-
assertListMultimapsEqual
public static <K,V> void assertListMultimapsEqual(String multimapName, ListMultimap<K,V> expectedListMultimap, ListMultimap<K,V> actualListMultimap)
-
assertSetMultimapsEqual
public static <K,V> void assertSetMultimapsEqual(SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)
-
assertSetMultimapsEqual
public static <K,V> void assertSetMultimapsEqual(String multimapName, SetMultimap<K,V> expectedSetMultimap, SetMultimap<K,V> actualSetMultimap)
-
assertBagMultimapsEqual
public static <K,V> void assertBagMultimapsEqual(BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)
-
assertBagMultimapsEqual
public static <K,V> void assertBagMultimapsEqual(String multimapName, BagMultimap<K,V> expectedBagMultimap, BagMultimap<K,V> actualBagMultimap)
-
assertSortedSetMultimapsEqual
public static <K,V> void assertSortedSetMultimapsEqual(SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)
-
assertSortedSetMultimapsEqual
public static <K,V> void assertSortedSetMultimapsEqual(String multimapName, SortedSetMultimap<K,V> expectedSortedSetMultimap, SortedSetMultimap<K,V> actualSortedSetMultimap)
-
assertSortedBagMultimapsEqual
public static <K,V> void assertSortedBagMultimapsEqual(SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)
-
assertSortedBagMultimapsEqual
public static <K,V> void assertSortedBagMultimapsEqual(String multimapName, SortedBagMultimap<K,V> expectedSortedBagMultimap, SortedBagMultimap<K,V> actualSortedBagMultimap)
-
assertContainsEntry
public static <K,V> void assertContainsEntry(K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)Assert that the givenMultimapcontains an entry with the given key and value.
-
assertContainsEntry
public static <K,V> void assertContainsEntry(String multimapName, K expectedKey, V expectedValue, Multimap<K,V> actualMultimap)
Assert that the givenMultimapcontains an entry with the given key and value.
-
assertContainsAllEntries
public static void assertContainsAllEntries(Multimap<?,?> actualMultimap, Object... keyValues)
Assert the givenMultimapcontains all the given keys and values.
-
assertContainsAllEntries
public static void assertContainsAllEntries(String multimapName, Multimap<?,?> actualMultimap, Object... expectedKeyValues)
Assert the givenMultimapcontains all the given keys and values.
-
denyContainsAny
public static void denyContainsAny(String collectionName, Collection<?> actualCollection, Object... items)
-
assertContainsKey
public static void assertContainsKey(Object expectedKey, Map<?,?> actualMap)
Assert that the givenMapcontains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(String mapName, Object expectedKey, Map<?,?> actualMap)
Assert that the givenMapcontains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(Object expectedKey, MapIterable<?,?> mapIterable)
Assert that the givenMapIterablecontains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(String mapIterableName, Object expectedKey, MapIterable<?,?> mapIterable)
Assert that the givenMapIterablecontains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterablecontains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(String mutableMapIterableName, Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterablecontains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterablecontains an entry with the given key.
-
assertContainsKey
public static void assertContainsKey(String immutableMapIterableName, Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterablecontains an entry with the given key.
-
denyContainsKey
public static void denyContainsKey(Object unexpectedKey, Map<?,?> actualMap)
Deny that the givenMapcontains an entry with the given key.
-
denyContainsKey
public static void denyContainsKey(String mapName, Object unexpectedKey, Map<?,?> actualMap)
Deny that the givenMapcontains an entry with the given key.
-
assertContainsKeyValue
public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, Map<?,?> actualMap)
Assert that the givenMapcontains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(String mapName, Object expectedKey, Object expectedValue, Map<?,?> actualMap)
Assert that the givenMapcontains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, MapIterable<?,?> mapIterable)
Assert that the givenMapIterablecontains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, MapIterable<?,?> mapIterable)
Assert that the givenMapIterablecontains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, MutableMapIterable<?,?> mapIterable)
Assert that the givenMutableMapIterablecontains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, MutableMapIterable<?,?> mutableMapIterable)
Assert that the givenMutableMapIterablecontains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, ImmutableMapIterable<?,?> mapIterable)
Assert that the givenImmutableMapIterablecontains an entry with the given key and value.
-
assertContainsKeyValue
public static void assertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, ImmutableMapIterable<?,?> immutableMapIterable)
Assert that the givenImmutableMapIterablecontains an entry with the given key and value.
-
assertNotContains
public static void assertNotContains(Object unexpectedItem, Collection<?> actualCollection)
Assert that the givenCollectiondoes not contain the given item.
-
assertNotContains
public static void assertNotContains(String collectionName, Object unexpectedItem, Collection<?> actualCollection)
Assert that the givenCollectiondoes not contain the given item.
-
assertNotContains
public static void assertNotContains(Object unexpectedItem, Iterable<?> iterable)
Assert that the givenIterabledoes not contain the given item.
-
assertNotContains
public static void assertNotContains(String collectionName, Object unexpectedItem, Iterable<?> iterable)
Assert that the givenIterabledoes not contain the given item.
-
assertNotContainsKey
public static void assertNotContainsKey(Object unexpectedKey, Map<?,?> actualMap)
Assert that the givenCollectiondoes not contain the given item.
-
assertNotContainsKey
public static void assertNotContainsKey(String mapName, Object unexpectedKey, Map<?,?> actualMap)
Assert that the givenCollectiondoes not contain the given item.
-
assertBefore
public static void assertBefore(Object formerItem, Object latterItem, List<?> actualList)
Assert that the formerItem appears before the latterItem in the givenCollection. Both the formerItem and the latterItem must appear in the collection, or this assert will fail.
-
assertBefore
public static void assertBefore(String listName, Object formerItem, Object latterItem, List<?> actualList)
Assert that the formerItem appears before the latterItem in the givenCollection.assertContains(String, Object, Collection)will be called for both the formerItem and the latterItem, prior to the "before" assertion.
-
assertItemAtIndex
public static void assertItemAtIndex(Object expectedItem, int index, List<?> list)
-
assertItemAtIndex
public static void assertItemAtIndex(Object expectedItem, int index, Object[] array)
Assert that the givenitemis at theindexin the givenarray.
-
assertStartsWith
public static <T> void assertStartsWith(T[] array, T... items)
-
assertStartsWith
public static <T> void assertStartsWith(List<T> list, T... items)
-
assertStartsWith
public static <T> void assertStartsWith(String listName, List<T> list, T... items)
-
assertEndsWith
public static <T> void assertEndsWith(List<T> list, T... items)
-
assertEndsWith
public static <T> void assertEndsWith(T[] array, T... items)
-
assertItemAtIndex
public static void assertItemAtIndex(String listName, Object expectedItem, int index, List<?> list)
-
assertItemAtIndex
public static void assertItemAtIndex(String arrayName, Object expectedItem, int index, Object[] array)
-
assertPostSerializedEqualsAndHashCode
public static void assertPostSerializedEqualsAndHashCode(Object object)
-
assertPostSerializedEqualsHashCodeAndToString
public static void assertPostSerializedEqualsHashCodeAndToString(Object object)
-
assertPostSerializedIdentity
public static void assertPostSerializedIdentity(Object object)
-
assertSerializedForm
public static void assertSerializedForm(String expectedBase64Form, Object actualObject)
-
assertSerializedForm
public static void assertSerializedForm(long expectedSerialVersionUID, String expectedBase64Form, Object actualObject)
-
assertDeserializedForm
public static void assertDeserializedForm(String expectedBase64Form, Object actualObject)
-
assertNotSerializable
public static void assertNotSerializable(Object actualObject)
-
assertEqualsAndHashCode
public static void assertEqualsAndHashCode(Object objectA, Object objectB)
Assert thatobjectAandobjectBare equal via theObject.equals(Object)method, and that they both return the sameObject.hashCode().
-
assertNegative
public static void assertNegative(int value)
Asserts that a value is negative.
-
assertPositive
public static void assertPositive(int value)
Asserts that a value is positive.
-
assertZero
public static void assertZero(int value)
Asserts that a value is positive.
-
assertEqualsAndHashCode
public static void assertEqualsAndHashCode(String itemNames, Object objectA, Object objectB)
Assert thatobjectAandobjectBare equal (via theObject.equals(Object)method, and that they both return the sameObject.hashCode().
-
assertShallowClone
@Deprecated public static void assertShallowClone(Cloneable object)
Deprecated.since 8.2.0 as will not work with Java 9
-
assertShallowClone
@Deprecated public static void assertShallowClone(String itemName, Cloneable object)
Deprecated.since 8.2.0 as will not work with Java 9
-
assertClassNonInstantiable
public static <T> void assertClassNonInstantiable(Class<T> aClass)
-
assertError
public static void assertError(Class<? extends Error> expectedErrorClass, Runnable code)
-
assertThrows
public static void assertThrows(Class<? extends Exception> expectedExceptionClass, Callable<?> code)
Runs theCallablecodeand asserts that it throws anExceptionof the typeexpectedExceptionClass.Callableis most appropriate when a checked exception will be thrown. If a subclass ofRuntimeExceptionwill be thrown, the formAssert.assertThrows(Class, org.junit.function.ThrowingRunnable)may be more convenient.e.g.
Verify.assertThrows(StringIndexOutOfBoundsException.class, new Callable<String>() { public String call() throws Exception { return "Craig".substring(42, 3); } });- See Also:
Assert.assertThrows(Class, org.junit.function.ThrowingRunnable)
-
assertThrowsWithCause
public static void assertThrowsWithCause(Class<? extends Exception> expectedExceptionClass, Class<? extends Throwable> expectedCauseClass, Callable<?> code)
Runs theCallablecodeand asserts that it throws anExceptionof the typeexpectedExceptionClass, which contains a cause of type expectedCauseClass.Callableis most appropriate when a checked exception will be thrown. If a subclass ofRuntimeExceptionwill be thrown, the formassertThrowsWithCause(Class, Class, Runnable)may be more convenient.e.g.
Verify.assertThrowsWithCause(RuntimeException.class, IOException.class, new Callable<Void>() { public Void call() throws Exception { try { new File("").createNewFile(); } catch (final IOException e) { throw new RuntimeException("Uh oh!", e); } return null; } });
-
assertThrowsWithCause
public static void assertThrowsWithCause(Class<? extends Exception> expectedExceptionClass, Class<? extends Throwable> expectedCauseClass, Runnable code)
Runs theRunnablecodeand asserts that it throws anExceptionof the typeexpectedExceptionClass, which contains a cause of type expectedCauseClass.Runnableis most appropriate when a subclass ofRuntimeExceptionwill be thrown. If a checked exception will be thrown, the formassertThrowsWithCause(Class, Class, Callable)may be more convenient.e.g.
Verify.assertThrowsWithCause(RuntimeException.class, StringIndexOutOfBoundsException.class, new Runnable() { public void run() { try { LOGGER.info("Craig".substring(42, 3)); } catch (final StringIndexOutOfBoundsException e) { throw new RuntimeException("Uh oh!", e); } } });
-
-