Skip to content

Most visited

Recently visited

navigation

ViewAssertion

public interface ViewAssertion

android.support.test.espresso.ViewAssertion


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.

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

Summary

Public methods

abstract void check(View view, 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).

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)
noViewFoundException NoMatchingViewException: an exception detailing why the view could not be found or null if the view was found
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.