# TestSummaryLogger

# TestSummaryLogger

Artifact:[androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/TestSummaryLogger.java+class:androidx.media3.test.utils.TestSummaryLogger)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/test/utils/TestSummaryLogger "View this page in Java")

<br />

```
@UnstableApi
class TestSummaryLogger
```

<br />

*** ** * ** ***

Utilities for logging test summaries in instrumentation tests.

## Summary

|                                    ### Public functions                                     |
|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [recordTestSkipped](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSummaryLogger#recordTestSkipped(android.content.Context,java.lang.String,java.lang.String))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!, testId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!, reason: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Log in logcat and in an analysis file that this test was skipped.                        |
| `java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [writeTestSummaryToFile](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSummaryLogger#writeTestSummaryToFile(android.content.Context,java.lang.String,org.json.JSONObject))`(` ` context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!,` ` testId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!,` ` testJson: `[JSONObject](https://developer.android.com/reference/org/json/JSONObject.html)`!` `)` Writes the summary of a test run to the application cache file. |

## Public functions

### recordTestSkipped

```
java-static fun recordTestSkipped(context: Context!, testId: String!, reason: String!): Unit
```

Log in logcat and in an analysis file that this test was skipped.

Analysis file is a JSON summarising the test, saved to the application cache.

The analysis json will contain a`skipReason`key, with the reason for skipping the test case.  

|                                            Throws                                             |
|-----------------------------------------------------------------------------------------------|---|
| [org.json.JSONException](https://developer.android.com/reference/org/json/JSONException.html) |   |
| [java.io.IOException](https://developer.android.com/reference/java/io/IOException.html)       |   |

### writeTestSummaryToFile

```
java-static fun writeTestSummaryToFile(
    context: Context!,
    testId: String!,
    testJson: JSONObject!
): Unit
```

Writes the summary of a test run to the application cache file.

The cache filename follows the pattern`<testId>-result.txt`.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html)`!`  | The[Context](https://developer.android.com/reference/android/content/Context.html).                                  |
| `testId: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | A unique identifier for the transformer test run.                                                                    |
| `testJson: `[JSONObject](https://developer.android.com/reference/org/json/JSONObject.html)`!`  | A[JSONObject](https://developer.android.com/reference/org/json/JSONObject.html)containing a summary of the test run. |

|                                            Throws                                             |
|-----------------------------------------------------------------------------------------------|---|
| [java.io.IOException](https://developer.android.com/reference/java/io/IOException.html)       |   |
| [org.json.JSONException](https://developer.android.com/reference/org/json/JSONException.html) |   |