Package: org.gradle.api.tasks.testing.logging

## [Java] Interface TestLogging

- Options that determine which test events get logged, and at which detail.

- - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `events(Object... events)` Sets the events to be logged.
    `int` | `getDisplayGranularity()` Returns the display granularity of the events to be logged.
    `Set<TestLogEvent>` | `getEvents()` Returns the events to be logged.
    `TestExceptionFormat` | `getExceptionFormat()` Returns the format to be used for logging test exceptions.
    `int` | `getMaxGranularity()` Returns the maximum granularity of the events to be logged.
    `int` | `getMinGranularity()` Returns the minimum granularity of the events to be logged.
    `boolean` | `getShowCauses()` Tells whether causes of exceptions that occur during test execution will be logged.
    `boolean` | `getShowExceptions()` Tells whether exceptions that occur during test execution will be logged.
    `boolean` | `getShowStackTraces()` Tells whether stack traces of exceptions that occur during test execution will be logged.
    `boolean` | `getShowStandardStreams()` Tells whether output on standard out and standard error will be logged.
    `Set<TestStackTraceFilter>` | `getStackTraceFilters()` Returns the set of filters to be used for sanitizing test stack traces.
    `void` | `setDisplayGranularity(int granularity)` Sets the display granularity of the events to be logged.
    `void` | `setEvents(Iterable<?> events)` Sets the events to be logged.
    `void` | `setExceptionFormat(Object exceptionFormat)` Sets the format to be used for logging test exceptions.
    `void` | `setMaxGranularity(int granularity)` Returns the maximum granularity of the events to be logged.
    `void` | `setMinGranularity(int granularity)` Sets the minimum granularity of the events to be logged.
    `void` | `setShowCauses(boolean flag)` Sets whether causes of exceptions that occur during test execution will be logged.
    `void` | `setShowExceptions(boolean flag)` Sets whether exceptions that occur during test execution will be logged.
    `void` | `setShowStackTraces(boolean flag)` Sets whether stack traces of exceptions that occur during test execution will be logged.
    `TestLogging` | `setShowStandardStreams(boolean flag)` Sets whether output on standard out and standard error will be logged.
    `void` | `setStackTraceFilters(Iterable<?> stackTraces)` Sets the set of filters to be used for sanitizing test stack traces.
    `void` | `stackTraceFilters(Object... stackTraces)` Convenience method for setStackTraceFilters(java.lang.Iterable).

- - ### Method Detail

    - #### public void events(Object... events)

      Sets the events to be logged. Events can be passed as enum values (e.g. TestLogEvent.FAILED) or Strings (e.g. "failed").

      Parameters:
        `events` - the events to be logged

    - #### public int getDisplayGranularity()

      Returns the display granularity of the events to be logged. For example, if set to 0, a method-level event will be displayed as "Test Run > Test Worker x > org.SomeClass > org.someMethod". If set to 2, the same event will be displayed as "org.someClass > org.someMethod".

      -1 denotes the highest granularity and corresponds to an atomic test.

      Returns:
        the display granularity of the events to be logged

    - #### public Set<TestLogEvent> getEvents()

      Returns the events to be logged.

      Returns:
        the events to be logged

    - #### public TestExceptionFormat getExceptionFormat()

      Returns the format to be used for logging test exceptions. Only relevant if `showStackTraces` is `true`.

      Returns:
        the format to be used for logging test exceptions

    - #### public int getMaxGranularity()

      Returns the maximum granularity of the events to be logged. Typically, 0 corresponds to the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values will vary if user-defined suites are executed.

      -1 denotes the highest granularity and corresponds to an atomic test.

      Returns:
        the maximum granularity of the events to be logged

    - #### public int getMinGranularity()

      Returns the minimum granularity of the events to be logged. Typically, 0 corresponds to the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values will vary if user-defined suites are executed.

      -1 denotes the highest granularity and corresponds to an atomic test.

      Returns:
        the minimum granularity of the events to be logged

    - #### public boolean getShowCauses()

      Tells whether causes of exceptions that occur during test execution will be logged. Only relevant if `showExceptions` is `true`.

      Returns:
        whether causes of exceptions that occur during test execution will be logged

    - #### public boolean getShowExceptions()

      Tells whether exceptions that occur during test execution will be logged. Typically these exceptions coincide with a "failed" event.

      Returns:
        whether exceptions that occur during test execution will be logged

    - #### public boolean getShowStackTraces()

      Tells whether stack traces of exceptions that occur during test execution will be logged.

      Returns:
        whether stack traces of exceptions that occur during test execution will be logged

    - #### public boolean getShowStandardStreams()

      Tells whether output on standard out and standard error will be logged. Equivalent to checking if both log events `TestLogEvent.STANDARD_OUT` and `TestLogEvent.STANDARD_ERROR` are set.

    - #### public Set<TestStackTraceFilter> getStackTraceFilters()

      Returns the set of filters to be used for sanitizing test stack traces.

      Returns:
        the set of filters to be used for sanitizing test stack traces

    - #### public void setDisplayGranularity(int granularity)

      Sets the display granularity of the events to be logged. For example, if set to 0, a method-level event will be displayed as "Test Run > Test Worker x > org.SomeClass > org.someMethod". If set to 2, the same event will be displayed as "org.someClass > org.someMethod".

      -1 denotes the highest granularity and corresponds to an atomic test.

      Parameters:
        `granularity` - the display granularity of the events to be logged

    - #### public void setEvents(Iterable<?> events)

      Sets the events to be logged.

      Parameters:
        `events` - the events to be logged

    - #### public void setExceptionFormat(Object exceptionFormat)

      Sets the format to be used for logging test exceptions. Only relevant if `showStackTraces` is `true`.

      Parameters:
        `exceptionFormat` - the format to be used for logging test exceptions

    - #### public void setMaxGranularity(int granularity)

      Returns the maximum granularity of the events to be logged. Typically, 0 corresponds to the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values will vary if user-defined suites are executed.

      -1 denotes the highest granularity and corresponds to an atomic test.

      Parameters:
        `granularity` - the maximum granularity of the events to be logged

    - #### public void setMinGranularity(int granularity)

      Sets the minimum granularity of the events to be logged. Typically, 0 corresponds to the Gradle-generated test suite for the whole test run, 1 corresponds to the Gradle-generated test suite for a particular test JVM, 2 corresponds to a test class, and 3 corresponds to a test method. These values will vary if user-defined suites are executed.

      -1 denotes the highest granularity and corresponds to an atomic test.

      Parameters:
        `granularity` - the minimum granularity of the events to be logged

    - #### public void setShowCauses(boolean flag)

      Sets whether causes of exceptions that occur during test execution will be logged. Only relevant if `showExceptions` is `true`.

      Parameters:
        `flag` - whether causes of exceptions that occur during test execution will be logged

    - #### public void setShowExceptions(boolean flag)

      Sets whether exceptions that occur during test execution will be logged.

      Parameters:
        `flag` - whether exceptions that occur during test execution will be logged

    - #### public void setShowStackTraces(boolean flag)

      Sets whether stack traces of exceptions that occur during test execution will be logged.

      Parameters:
        `flag` - whether stack traces of exceptions that occur during test execution will be logged

    - #### public TestLogging setShowStandardStreams(boolean flag)

      Sets whether output on standard out and standard error will be logged. Equivalent to setting log events `TestLogEvent.STANDARD_OUT` and `TestLogEvent.STANDARD_ERROR`.

    - #### public void setStackTraceFilters(Iterable<?> stackTraces)

      Sets the set of filters to be used for sanitizing test stack traces.

      Parameters:
        `stackTraces` - the set of filters to be used for sanitizing test stack traces

    - #### public void stackTraceFilters(Object... stackTraces)

      Convenience method for setStackTraceFilters(java.lang.Iterable). Accepts both enum values and Strings.