Search code examples
androidtestingandroid-contentprovider

Testing content providers with ProviderTestCase2


I am trying to test my content provider following the snippet in this answer

https://stackoverflow.com/a/35680611/12652258

The post mentions that the Test must not be run with AndroidJUnit4 runner -Test of course must be run as android instrumented test

How do I achieve this ?

1: Running an instrumented test without using AndroidJUnit4 runner ?

2: Where do I place the test files in my project? In the test folder or androidTest folder ?


Solution

  • I figured it out.

    You place your files in the androidTest directory.

    Remove the annotation @RunWith(AndroidJUnit4::class)

    Make sure your method is prefixed with the word test. Everything should run just fine if you follow this answer given in this post.

    https://stackoverflow.com/a/35680611/12652258