# ResultsReporter

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/ResultsReporter.kt+class:androidx.test.uiautomator.ResultsReporter) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

*** ** * ** ***


```
public final class ResultsReporter
```

<br />

*** ** * ** ***

Allows to report test results to Android Studio. This is helpful especially when debugging a test.

For example:

```
val file = resultsReporter.addNewFile("filename.jpg", "MyButton")
bitmap.saveToFile(file)
```

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/test/uiautomator/ResultsReporter#ResultsReporter(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html testName)` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/File.html` | `https://developer.android.com/reference/androidx/test/uiautomator/ResultsReporter#addNewFile(kotlin.String,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html filename, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html title)` Returns a new file to add to the test results for Android Studio. |
| `final void` | `https://developer.android.com/reference/androidx/test/uiautomator/ResultsReporter#reportToInstrumentation()()` At the end of the test execution reports to Android Studio what files need to be pulled that were previously added with `https://developer.android.com/reference/androidx/test/uiautomator/ResultsReporter#addNewFile(kotlin.String,kotlin.String)`. |

## Public constructors

### ResultsReporter

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public ResultsReporter(@NonNull String testName)
```

## Public methods

### addNewFile

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public final @NonNull File addNewFile(@NonNull String filename, @NonNull String title)
```

Returns a new file to add to the test results for Android Studio. The file will be created with the given `https://developer.android.com/reference/androidx/test/uiautomator/ResultsReporter#addNewFile(kotlin.String,kotlin.String)` and reported with the given `https://developer.android.com/reference/androidx/test/uiautomator/ResultsReporter#addNewFile(kotlin.String,kotlin.String)`. In order to be recognized from android studio, the file needs to be created in .

Usage example:

```
val file = resultsReporter.addNewFile("filename.jpg", "MyButton")
bitmap.saveToFile(file)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html filename` | the name of the file to add for reporting. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html title` | a title to use when reporting to Android Studio. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/File.html` | a `https://developer.android.com/reference/java/io/File.html` for the file to report to Android Studio. |

### reportToInstrumentation

Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public final void reportToInstrumentation()
```

At the end of the test execution reports to Android Studio what files need to be pulled that were previously added with `https://developer.android.com/reference/androidx/test/uiautomator/ResultsReporter#addNewFile(kotlin.String,kotlin.String)`.