# FragmentScenario.FragmentAction

# FragmentScenario.FragmentAction

Artifact:[androidx.fragment:fragment-testing](https://developer.android.com/jetpack/androidx/releases/fragment)  
[View Source](https://cs.android.com/search?q=file:androidx/fragment/app/testing/FragmentScenario.kt+class:androidx.fragment.app.testing.FragmentScenario.FragmentAction)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/fragment/app/testing/FragmentScenario.FragmentAction "View this page in Java")

<br />

```
fun interface FragmentScenario.FragmentAction<F : Fragment>
```

<br />

*** ** * ** ***

FragmentAction interface should be implemented by any class whose instances are intended to be executed by the main thread. A Fragment that is instrumented by the FragmentScenario is passed to[FragmentAction.perform](https://developer.android.com/reference/kotlin/androidx/fragment/app/testing/FragmentScenario.FragmentAction#perform(androidx.fragment.app.Fragment))method.

You should never keep the Fragment reference as it will lead to unpredictable behaviour. It should only be accessed in[FragmentAction.perform](https://developer.android.com/reference/kotlin/androidx/fragment/app/testing/FragmentScenario.FragmentAction#perform(androidx.fragment.app.Fragment))scope.

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [perform](https://developer.android.com/reference/kotlin/androidx/fragment/app/testing/FragmentScenario.FragmentAction#perform(androidx.fragment.app.Fragment))`(fragment: F)` This method is invoked on the main thread with the reference to the Fragment. |

## Public functions

### perform

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/fragment#1.1.0)  

```
fun perform(fragment: F): Unit
```

This method is invoked on the main thread with the reference to the Fragment.  

|  Parameters   |
|---------------|--------------------------------------------------|
| `fragment: F` | a Fragment instrumented by the FragmentScenario. |