Content Provider Design and Testing
In Android, content providers are viewed externally as data APIs that provide tables of data, with their internals hidden from view. A content provider may have many public constants, but it usually has few if any public methods and no public variables. This suggests that you should write your tests based only on the provider's public members. A content provider that is designed like this is offering a contract between itself and its users.
The base test case class for content providers,
ProviderTestCase2, allows you to test your content provider in an
isolated environment. Android mock objects such as IsolatedContext and
MockContentResolver also help provide an isolated test environment.
As with other Android tests, provider test packages are run under the control of the test runner
InstrumentationTestRunner. The section
Running Tests With InstrumentationTestRunner describes the test runner in
more detail. The topic
Testing From Eclipse with ADT shows you how to run a test package in Eclipse, and the
topic
Testing From Other IDEs
shows you how to run a test package from the command line
RSS Feed
Twitter
0 comments:
Post a Comment