Auto-tools/Projects/Robocop/WritingTests: Difference between revisions

Jump to navigation Jump to search
Line 37: Line 37:
== Creating a new Content Provider test ==
== Creating a new Content Provider test ==


We have infrastructure for testing content providers in an isolated environment. This means that we ensure that any updates to the databases behind content providers will not affect or be affected by the Fennec app.
We have infrastructure for testing content providers in an isolated environment. This means that we ensure that any updates to the databases behind content providers will not affect or be affected by Firefox.


To write a content provider test, you should follow the same file naming and Java packaging guidelines described for UI tests. However, you should create a class that inherits from ''ContentProviderTest'' instead of ''BaseTest'' or ''ActivityInstrumentationTestCase2''. Each Content Provider test class must have the same three methods as UI tests (setUp(), test[YourFeature]() and tearDown) with one important difference: the ''setUp()'' method should call the following parent method:
To write a content provider test, follow the same file naming and Java packaging guidelines described for UI tests, but create a class that inherits from ''ContentProviderTest'' instead of ''BaseTest''. Each Content Provider test class must have the same three methods as UI tests (setUp(), test[YourFeature]() and tearDown) with one important difference: the ''setUp()'' method should call the following parent method:


<pre>
<pre>
Line 54: Line 54:
</pre>
</pre>


After this is called, ''mProvider'' will point to your an isolated instance of your content provider and you can make insert/query/update/delete calls on it as expected. For more details and sample code on how to implement Content Provider tests, have a look at the testBrowserProvider.java.in.
After this is called, ''mProvider'' will point to an isolated instance of your content provider and you can make insert/query/update/delete calls on it as expected. For more details and sample code on how to implement Content Provider tests, see testBrowserProvider.java.in.


= APIs  =
= APIs  =
Confirmed users
1,759

edits

Navigation menu