I wrote that my content provider was supposed to wrap access to 2 tables in the SqlLite database. Now I would like to write some test cases, but I never did it. After reading the section in the developer's guide, I have to say that I was not able to verify anything.
Below is my code for now. This is the only class in the test project that matches my main project. When I run it in Eclipse, the emulator starts correctly, the packages are installed, but it does not run the test:
Test run failed: test run incomplete. Expected 1 tests received 0
Here is a test class:
public class ArticleProviderTest extends ProviderTestCase2<ArticleProvider> { static final Uri[] validUris = new Uri[] { Articles.CONTENT_URI, Pictures.CONTENT_URI, Pictures.getContentUriForArticleId(1) }; public ArticleProviderTest(Class<ArticleProvider> providerClass, String providerAuthority) { super(providerClass, providerAuthority); } @Override protected void setUp() throws Exception { super.setUp(); } public void testQuery() { ContentProvider provider = getProvider(); for (Uri uri : validUris) { Cursor cursor = provider.query(uri, null, null, null, null); assertNotNull(cursor); } } }
And the manifest file, if that helps:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="fr.marvinlabs.xxxx" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="7" /> <instrumentation android:targetPackage="fr.marvinlabs.xxxx" android:name="android.test.InstrumentationTestRunner" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <uses-library android:name="android.test.runner" /> </application> </manifest>
When I run the debug configuration, breakpoints in the constructor and in setUp do not start.?!
I also did not find much information on the net. Can someone help me understand how to set up testing (basically create a test database file, fill it with some data, request it ...)?
Vincent mimoun-prat
source share