Book Image

Learning Android Application Testing

Book Image

Learning Android Application Testing

Overview of this book

Table of Contents (16 chapters)
Learning Android Application Testing
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

View assertions


The assertions introduced earlier handle a variety of types as parameters, but they are only intended to test simple conditions or simple objects.

For example, we have asertEquals(short expected, short actual) to test short values, assertEquals(int expected, int actual) to test integer values, assertEquals(Object expected, Object expected) to test any Object instance, and so on.

Usually, while testing user interfaces in Android, you will face the problem of more sophisticated methods, which are mainly related with Views. In this respect, Android provides a class with plenty of assertions in android.test.ViewAsserts (see http://developer.android.com/reference/android/test/ViewAsserts.html for more details), which test relationships between Views and their absolute and relative positions on the screen.

These methods are also overloaded to provide different conditions. Among the assertions, we can find the following:

  • assertBaselineAligned: This asserts that two Views are aligned...