Package: groovy.org.codenarc.test

## [Groovy] Class TestUtil

- groovy.org.codenarc.test.TestUtil

- Contains common static utility methods for tests

  Authors:
    Chris Mair

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static void` | `assertContainsAll(String text, def strings)` Assert that the text contains each of the specified strings
    `` | `static void` | `assertContainsAllInOrder(String text, def strings)` Assert that the text contains each of the specified strings, in order
    `` | `static void` | `assertEqualSets(Collection collection1, Collection collection2)` Assert that the two collections have equal Sets of elements.
    `` | `static List<org.apache.log4j.spi.LoggingEvent>` | `captureLog4JMessages(groovy.lang.Closure closure)`
    `` | `static String` | `captureSystemOut(groovy.lang.Closure closure)`
    `` | `static boolean` | `containsAll(String text, def strings)` Return true if the text contains each of the specified strings
    `` | `static String` | `shouldFail(Class expectedExceptionClass, groovy.lang.Closure code)` Assert that the specified code throws an exception of the specified type.
    `` | `static String` | `shouldFail(groovy.lang.Closure code)` Assert that the specified code throws an exception (of any type).
    `` | `static String` | `shouldFailWithMessageContaining(Class expectedExceptionClass, String expectedText, groovy.lang.Closure code)` Assert that the specified code throws an exception whose message contains the specified text.
    `` | `static void` | `shouldFailWithMessageContaining(def text, groovy.lang.Closure closure)` Assert that the specified closure should throw an exception whose message contains text

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, toString, hashCode, getClass, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### static void assertContainsAll(String text, def strings)

      Assert that the text contains each of the specified strings

      Parameters:
        `text` - - the text to search
        `strings` - - the Strings that must be present within text; toString() is invoked on each element

    - #### static void assertContainsAllInOrder(String text, def strings)

      Assert that the text contains each of the specified strings, in order

      Parameters:
        `text` - - the text to search
        `strings` - - the Strings that must be present within text, and appear in the order specified; toString() is applied to each.

    - #### static void assertEqualSets(Collection collection1, Collection collection2)

      Assert that the two collections have equal Sets of elements. In other words, assert that the two collections are the same, ignoring ordering and duplicates.

    - #### static List<org.apache.log4j.spi.LoggingEvent> captureLog4JMessages(groovy.lang.Closure closure)

    - #### static String captureSystemOut(groovy.lang.Closure closure)

    - #### static boolean containsAll(String text, def strings)

      Return true if the text contains each of the specified strings

      Parameters:
        `text` - - the text to search
        `strings` - - the Strings to check for; toString() is invoked on each element

    - #### static String shouldFail(Class expectedExceptionClass, groovy.lang.Closure code)

      Assert that the specified code throws an exception of the specified type. Return the thrown exception message.

      throws:
        AssertionError - if no exception is thrown by the code or if the thrown exception is not of the expected type
      Parameters:
        `expectedExceptionClass` - - the Class of exception that is expected; may be null
        `code` - - the Closure containing the code to be executed, which is expected to throw an exception of the specified type
      Returns:
        the message from the thrown Exception

    - #### static String shouldFail(groovy.lang.Closure code)

      Assert that the specified code throws an exception (of any type). Return the thrown exception message.

      throws:
        AssertionError - if no exception is thrown by the code or if the thrown exception is not of the expected type
      Parameters:
        `code` - - the Closure containing the code to be executed, which is expected to throw an exception of the specified type
      Returns:
        the message from the thrown Exception

    - #### static String shouldFailWithMessageContaining(Class expectedExceptionClass, String expectedText, groovy.lang.Closure code)

      Assert that the specified code throws an exception whose message contains the specified text.

      throws:
        AssertionError - if no exception is thrown by the code or if the text is not contained in the exception message
      Parameters:
        `expectedExceptionClass` - - the class of the Throwable that is expected to be thrown
        `expectedText` - - the text expected within the exception message
        `code` - - the Closure containing the code to be executed, which is expected to throw an exception of the specified type
      Returns:
        the thrown Exception message

    - #### static void shouldFailWithMessageContaining(def text, groovy.lang.Closure closure)

      Assert that the specified closure should throw an exception whose message contains text

      Parameters:
        `text` - - the text expected within the message; may be a single String or a List of Strings
        `closure` - - the Closure to execute