Warm tip: This article is reproduced from serverfault.com, please click

Testing content providers with ProviderTestCase2

发布于 2020-11-28 08:32:24

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 ?

Questioner
Tendai
Viewed
0
Tendai 2020-11-28 18:36:10

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