# ViewAssertion

# ViewAssertion

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


interface
ViewAssertion
`  
`


`

|---------------------------------------------|
| android.support.test.espresso.ViewAssertion |

<br />

*** ** * ** ***

Responsible for performing assertions on a View element.  

This is considered part of the test framework public API - developers are free to write their own assertions as long as they meet the following requirements:

- Do not mutate the passed in view.
- Throw junit.framework.AssertionError when the view assertion does not hold.
- Implementation runs on the UI thread - so it should not do any blocking operations
- Downcasting the view to a specific type is allowed, provided there is a test that view is an instance of that type before downcasting. If not, an AssertionError should be thrown.
- It is encouraged to access non-mutating methods on the view to perform assertion.

<br />

Strongly consider using a existing ViewAssertion via the ViewAssertions utility class before writing your own assertion.

## Summary

|                                                                                                                                                                                                                                          ### Public methods                                                                                                                                                                                                                                          ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void` | ` `[check](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion#check(android.view.View, android.support.test.espresso.NoMatchingViewException))`(`[View](https://developer.android.com/reference/android/view/View.html)` view, `[NoMatchingViewException](https://developer.android.com/reference/android/support/test/espresso/NoMatchingViewException)` noViewFoundException) ` Checks the state of the given view (if such a view is present). |

## Public methods

### check

```
void check (View view, 
                NoMatchingViewException noViewFoundException)
```

Checks the state of the given view (if such a view is present).

<br />

|                                                                                Parameters                                                                                ||
|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `view`                 | `View`: the view, if one was found during the view interaction or null if it was not (which may be an acceptable option for an assertion) <br /> |
| `noViewFoundException` | `NoMatchingViewException`: an exception detailing why the view could not be found or null if the view was found <br />                           |

-

  ## Interfaces

  - [EspressoException](https://developer.android.com/reference/android/support/test/espresso/EspressoException)
  - [FailureHandler](https://developer.android.com/reference/android/support/test/espresso/FailureHandler)
  - [IdlingResource](https://developer.android.com/reference/android/support/test/espresso/IdlingResource)
  - [IdlingResource.ResourceCallback](https://developer.android.com/reference/android/support/test/espresso/IdlingResource.ResourceCallback)
  - [UiController](https://developer.android.com/reference/android/support/test/espresso/UiController)
  - [ViewAction](https://developer.android.com/reference/android/support/test/espresso/ViewAction)
  - [ViewAssertion](https://developer.android.com/reference/android/support/test/espresso/ViewAssertion)
  - [ViewFinder](https://developer.android.com/reference/android/support/test/espresso/ViewFinder)
  - [ViewInteractionComponent](https://developer.android.com/reference/android/support/test/espresso/ViewInteractionComponent)
-

  ## Classes

  - [AmbiguousViewMatcherException.Builder](https://developer.android.com/reference/android/support/test/espresso/AmbiguousViewMatcherException.Builder)
  - [DataInteraction](https://developer.android.com/reference/android/support/test/espresso/DataInteraction)
  - [DataInteraction.DisplayDataMatcher](https://developer.android.com/reference/android/support/test/espresso/DataInteraction.DisplayDataMatcher)
  - [Espresso](https://developer.android.com/reference/android/support/test/espresso/Espresso)
  - [IdlingPolicies](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicies)
  - [IdlingPolicy](https://developer.android.com/reference/android/support/test/espresso/IdlingPolicy)
  - [IdlingRegistry](https://developer.android.com/reference/android/support/test/espresso/IdlingRegistry)
  - [NoMatchingViewException.Builder](https://developer.android.com/reference/android/support/test/espresso/NoMatchingViewException.Builder)
  - [PerformException.Builder](https://developer.android.com/reference/android/support/test/espresso/PerformException.Builder)
  - [Root](https://developer.android.com/reference/android/support/test/espresso/Root)
  - [Root.Builder](https://developer.android.com/reference/android/support/test/espresso/Root.Builder)
  - [ViewInteraction](https://developer.android.com/reference/android/support/test/espresso/ViewInteraction)
-

  ## Exceptions

  - [AmbiguousViewMatcherException](https://developer.android.com/reference/android/support/test/espresso/AmbiguousViewMatcherException)
  - [AppNotIdleException](https://developer.android.com/reference/android/support/test/espresso/AppNotIdleException)
  - [IdlingResourceTimeoutException](https://developer.android.com/reference/android/support/test/espresso/IdlingResourceTimeoutException)
  - [InjectEventSecurityException](https://developer.android.com/reference/android/support/test/espresso/InjectEventSecurityException)
  - [NoActivityResumedException](https://developer.android.com/reference/android/support/test/espresso/NoActivityResumedException)
  - [NoMatchingRootException](https://developer.android.com/reference/android/support/test/espresso/NoMatchingRootException)
  - [NoMatchingViewException](https://developer.android.com/reference/android/support/test/espresso/NoMatchingViewException)
  - [PerformException](https://developer.android.com/reference/android/support/test/espresso/PerformException)