Class Verify

java.lang.Object
org.junit.Assert
org.eclipse.collections.impl.test.Verify

public final class Verify extends Assert
An extension of the Assert class, 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 Details

    • throwMangledException

      public static void throwMangledException(AssertionError e)
      Mangles the stack trace of AssertionError so 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 other throwMangledException(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

      public static void throwMangledException(AssertionError e, int framesToPop)
      Mangles the stack trace of AssertionError so 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 ... catch block 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 ... catch block 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.
    • fail

      public static void fail(String message, Throwable cause)
    • assertEmpty

      public static void assertEmpty(Iterable<?> actualIterable)
      Assert that the given Iterable is empty.
    • assertEmpty

      public static void assertEmpty(String iterableName, Iterable<?> actualIterable)
      Assert that the given Collection is empty.
    • assertEmpty

      public static void assertEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
      Assert that the given MutableMapIterable is empty.
    • assertEmpty

      public static void assertEmpty(String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
      Assert that the given Collection is empty.
    • assertEmpty

      public static void assertEmpty(PrimitiveIterable primitiveIterable)
      Assert that the given PrimitiveIterable is empty.
    • assertEmpty

      public static void assertEmpty(String iterableName, PrimitiveIterable primitiveIterable)
      Assert that the given PrimitiveIterable is empty.
    • assertIterableEmpty

      public static void assertIterableEmpty(Iterable<?> iterable)
      Assert that the given Iterable is empty.
    • assertIterableEmpty

      public static void assertIterableEmpty(String iterableName, Iterable<?> iterable)
      Assert that the given Iterable is 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 given Map is empty.
    • assertEmpty

      public static void assertEmpty(Multimap<?,?> actualMultimap)
      Assert that the given Multimap is empty.
    • assertEmpty

      public static void assertEmpty(String multimapName, Multimap<?,?> actualMultimap)
      Assert that the given Multimap is empty.
    • assertEmpty

      public static void assertEmpty(String mapName, Map<?,?> actualMap)
      Assert that the given Map is empty.
    • assertNotEmpty

      public static void assertNotEmpty(Iterable<?> actualIterable)
      Assert that the given Iterable is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(String iterableName, Iterable<?> actualIterable)
      Assert that the given Iterable is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(MutableMapIterable<?,?> actualMutableMapIterable)
      Assert that the given MutableMapIterable is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(String mutableMapIterableName, MutableMapIterable<?,?> actualMutableMapIterable)
      Assert that the given MutableMapIterable is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(PrimitiveIterable primitiveIterable)
      Assert that the given PrimitiveIterable is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(String iterableName, PrimitiveIterable primitiveIterable)
      Assert that the given PrimitiveIterable is not empty.
    • assertIterableNotEmpty

      public static void assertIterableNotEmpty(Iterable<?> iterable)
      Assert that the given Iterable is not empty.
    • assertIterableNotEmpty

      public static void assertIterableNotEmpty(String iterableName, Iterable<?> iterable)
      Assert that the given Iterable is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(Map<?,?> actualMap)
      Assert that the given Map is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(String mapName, Map<?,?> actualMap)
      Assert that the given Map is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(Multimap<?,?> actualMultimap)
      Assert that the given Multimap is not empty.
    • assertNotEmpty

      public static void assertNotEmpty(String multimapName, Multimap<?,?> actualMultimap)
      Assert that the given Multimap is 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 given Iterable.
    • assertSize

      public static void assertSize(String iterableName, int expectedSize, Iterable<?> actualIterable)
      Assert the size of the given Iterable.
    • assertSize

      public static void assertSize(int expectedSize, PrimitiveIterable primitiveIterable)
      Assert the size of the given PrimitiveIterable.
    • assertSize

      public static void assertSize(String primitiveIterableName, int expectedSize, PrimitiveIterable actualPrimitiveIterable)
      Assert the size of the given PrimitiveIterable.
    • assertIterableSize

      public static void assertIterableSize(int expectedSize, Iterable<?> actualIterable)
      Assert the size of the given Iterable.
    • assertIterableSize

      public static void assertIterableSize(String iterableName, int expectedSize, Iterable<?> actualIterable)
      Assert the size of the given Iterable.
    • assertSize

      public static void assertSize(String mapName, int expectedSize, Map<?,?> actualMap)
      Assert the size of the given Map.
    • assertSize

      public static void assertSize(int expectedSize, Map<?,?> actualMap)
      Assert the size of the given Map.
    • assertSize

      public static void assertSize(int expectedSize, Multimap<?,?> actualMultimap)
      Assert the size of the given Multimap.
    • assertSize

      public static void assertSize(String multimapName, int expectedSize, Multimap<?,?> actualMultimap)
      Assert the size of the given Multimap.
    • assertSize

      public static void assertSize(int expectedSize, MutableMapIterable<?,?> mutableMapIterable)
      Assert the size of the given MutableMapIterable.
    • assertSize

      public static void assertSize(String mapName, int expectedSize, MutableMapIterable<?,?> mutableMapIterable)
      Assert the size of the given MutableMapIterable.
    • assertSize

      public static void assertSize(int expectedSize, ImmutableSet<?> actualImmutableSet)
      Assert the size of the given ImmutableSet.
    • assertSize

      public static void assertSize(String immutableSetName, int expectedSize, ImmutableSet<?> actualImmutableSet)
      Assert the size of the given ImmutableSet.
    • assertContains

      public static void assertContains(String stringToFind, String stringToSearch)
      Assert that the given stringToFind is contained within the stringToSearch.
    • assertNotContains

      public static void assertNotContains(String unexpectedString, String stringToSearch)
      Assert that the given unexpectedString is not contained within the stringToSearch.
    • assertContains

      public static void assertContains(String stringName, String stringToFind, String stringToSearch)
      Assert that the given stringToFind is contained within the stringToSearch.
    • assertNotContains

      public static void assertNotContains(String stringName, String unexpectedString, String stringToSearch)
      Assert that the given unexpectedString is not contained within the stringToSearch.
    • 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 given Map contains all the given keys and values.
    • assertContainsAllKeyValues

      public static void assertContainsAllKeyValues(String mapName, Map<?,?> actualMap, Object... expectedKeyValues)
      Assert that the given Map contains all the given keys and values.
    • assertContainsAllKeyValues

      public static void assertContainsAllKeyValues(MapIterable<?,?> mapIterable, Object... keyValues)
      Assert that the given MapIterable contains all the given keys and values.
    • assertContainsAllKeyValues

      public static void assertContainsAllKeyValues(String mapIterableName, MapIterable<?,?> mapIterable, Object... expectedKeyValues)
      Assert that the given MapIterable contains all the given keys and values.
    • assertContainsAllKeyValues

      public static void assertContainsAllKeyValues(MutableMapIterable<?,?> mutableMapIterable, Object... keyValues)
      Assert that the given MutableMapIterable contains all the given keys and values.
    • assertContainsAllKeyValues

      public static void assertContainsAllKeyValues(String mutableMapIterableName, MutableMapIterable<?,?> mutableMapIterable, Object... expectedKeyValues)
      Assert that the given MutableMapIterable contains all the given keys and values.
    • assertContainsAllKeyValues

      public static void assertContainsAllKeyValues(ImmutableMapIterable<?,?> immutableMapIterable, Object... keyValues)
      Assert that the given ImmutableMapIterable contains all the given keys and values.
    • assertContainsAllKeyValues

      public static void assertContainsAllKeyValues(String immutableMapIterableName, ImmutableMapIterable<?,?> immutableMapIterable, Object... expectedKeyValues)
      Assert that the given ImmutableMapIterable contains 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 given Collection contains the given item.
    • assertContains

      public static void assertContains(String collectionName, Object expectedItem, Collection<?> actualCollection)
      Assert that the given Collection contains the given item.
    • assertContains

      public static void assertContains(Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
      Assert that the given ImmutableCollection contains the given item.
    • assertContains

      public static void assertContains(String immutableCollectionName, Object expectedItem, ImmutableCollection<?> actualImmutableCollection)
      Assert that the given ImmutableCollection contains the given item.
    • assertContainsAll

      public static void assertContainsAll(Iterable<?> iterable, Object... items)
    • assertContainsAll

      public static void assertContainsAll(String collectionName, Iterable<?> iterable, Object... items)
    • assertListsEqual

      public static void assertListsEqual(List<?> expectedList, List<?> actualList)
    • assertListsEqual

      public static void assertListsEqual(String listName, List<?> expectedList, List<?> actualList)
    • assertSetsEqual

      public static void assertSetsEqual(Set<?> expectedSet, Set<?> actualSet)
    • 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(Map<?,?> expectedMap, Map<?,?> actualMap)
    • assertMapsEqual

      public static void assertMapsEqual(String mapName, Map<?,?> expectedMap, Map<?,?> actualMap)
    • assertBagsEqual

      public static void assertBagsEqual(Bag<?> expectedBag, Bag<?> actualBag)
    • 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 given Multimap contains 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 given Multimap contains an entry with the given key and value.
    • assertContainsAllEntries

      public static void assertContainsAllEntries(Multimap<?,?> actualMultimap, Object... keyValues)
      Assert the given Multimap contains all the given keys and values.
    • assertContainsAllEntries

      public static void assertContainsAllEntries(String multimapName, Multimap<?,?> actualMultimap, Object... expectedKeyValues)
      Assert the given Multimap contains 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 given Map contains an entry with the given key.
    • assertContainsKey

      public static void assertContainsKey(String mapName, Object expectedKey, Map<?,?> actualMap)
      Assert that the given Map contains an entry with the given key.
    • assertContainsKey

      public static void assertContainsKey(Object expectedKey, MapIterable<?,?> mapIterable)
      Assert that the given MapIterable contains an entry with the given key.
    • assertContainsKey

      public static void assertContainsKey(String mapIterableName, Object expectedKey, MapIterable<?,?> mapIterable)
      Assert that the given MapIterable contains an entry with the given key.
    • assertContainsKey

      public static void assertContainsKey(Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
      Assert that the given MutableMapIterable contains an entry with the given key.
    • assertContainsKey

      public static void assertContainsKey(String mutableMapIterableName, Object expectedKey, MutableMapIterable<?,?> mutableMapIterable)
      Assert that the given MutableMapIterable contains an entry with the given key.
    • assertContainsKey

      public static void assertContainsKey(Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
      Assert that the given ImmutableMapIterable contains an entry with the given key.
    • assertContainsKey

      public static void assertContainsKey(String immutableMapIterableName, Object expectedKey, ImmutableMapIterable<?,?> immutableMapIterable)
      Assert that the given ImmutableMapIterable contains an entry with the given key.
    • denyContainsKey

      public static void denyContainsKey(Object unexpectedKey, Map<?,?> actualMap)
      Deny that the given Map contains an entry with the given key.
    • denyContainsKey

      public static void denyContainsKey(String mapName, Object unexpectedKey, Map<?,?> actualMap)
      Deny that the given Map contains an entry with the given key.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, Map<?,?> actualMap)
      Assert that the given Map contains an entry with the given key and value.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(String mapName, Object expectedKey, Object expectedValue, Map<?,?> actualMap)
      Assert that the given Map contains an entry with the given key and value.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, MapIterable<?,?> mapIterable)
      Assert that the given MapIterable contains an entry with the given key and value.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, MapIterable<?,?> mapIterable)
      Assert that the given MapIterable contains an entry with the given key and value.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, MutableMapIterable<?,?> mapIterable)
      Assert that the given MutableMapIterable contains an entry with the given key and value.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, MutableMapIterable<?,?> mutableMapIterable)
      Assert that the given MutableMapIterable contains an entry with the given key and value.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(Object expectedKey, Object expectedValue, ImmutableMapIterable<?,?> mapIterable)
      Assert that the given ImmutableMapIterable contains an entry with the given key and value.
    • assertContainsKeyValue

      public static void assertContainsKeyValue(String mapIterableName, Object expectedKey, Object expectedValue, ImmutableMapIterable<?,?> immutableMapIterable)
      Assert that the given ImmutableMapIterable contains an entry with the given key and value.
    • assertNotContains

      public static void assertNotContains(Object unexpectedItem, Collection<?> actualCollection)
      Assert that the given Collection does not contain the given item.
    • assertNotContains

      public static void assertNotContains(String collectionName, Object unexpectedItem, Collection<?> actualCollection)
      Assert that the given Collection does not contain the given item.
    • assertNotContains

      public static void assertNotContains(Object unexpectedItem, Iterable<?> iterable)
      Assert that the given Iterable does not contain the given item.
    • assertNotContains

      public static void assertNotContains(String collectionName, Object unexpectedItem, Iterable<?> iterable)
      Assert that the given Iterable does not contain the given item.
    • assertNotContainsKey

      public static void assertNotContainsKey(Object unexpectedKey, Map<?,?> actualMap)
      Assert that the given Collection does not contain the given item.
    • assertNotContainsKey

      public static void assertNotContainsKey(String mapName, Object unexpectedKey, Map<?,?> actualMap)
      Assert that the given Collection does 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 given Collection. 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 given Collection. assertContains(String, Object, Collection) will be called for both the formerItem and the latterItem, prior to the "before" assertion.
    • assertObjectNotNull

      public static void assertObjectNotNull(String objectName, Object actualObject)
    • assertItemAtIndex

      public static void assertItemAtIndex(Object expectedItem, int index, List<?> list)
      Assert that the given item is at the index in the given List.
    • assertItemAtIndex

      public static void assertItemAtIndex(Object expectedItem, int index, Object[] array)
      Assert that the given item is at the index in the given array.
    • 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)
      Assert that the given item is at the index in the given List.
    • assertItemAtIndex

      public static void assertItemAtIndex(String arrayName, Object expectedItem, int index, Object[] array)
      Assert that the given item is at the index in the given List.
    • 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 that objectA and objectB are equal via the Object.equals(Object) method, and that they both return the same Object.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 that objectA and objectB are equal (via the Object.equals(Object) method, and that they both return the same Object.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 the Callable code and asserts that it throws an Exception of the type expectedExceptionClass.

      Callable is most appropriate when a checked exception will be thrown. If a subclass of RuntimeException will be thrown, the form Assert.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:
    • assertThrowsWithCause

      public static void assertThrowsWithCause(Class<? extends Exception> expectedExceptionClass, Class<? extends Throwable> expectedCauseClass, Callable<?> code)
      Runs the Callable code and asserts that it throws an Exception of the type expectedExceptionClass, which contains a cause of type expectedCauseClass.

      Callable is most appropriate when a checked exception will be thrown. If a subclass of RuntimeException will be thrown, the form assertThrowsWithCause(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;
          }
       });
       
      See Also:
    • assertThrowsWithCause

      public static void assertThrowsWithCause(Class<? extends Exception> expectedExceptionClass, Class<? extends Throwable> expectedCauseClass, Runnable code)
      Runs the Runnable code and asserts that it throws an Exception of the type expectedExceptionClass, which contains a cause of type expectedCauseClass.

      Runnable is most appropriate when a subclass of RuntimeException will be thrown. If a checked exception will be thrown, the form assertThrowsWithCause(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);
              }
          }
       });
       
      See Also: