On testing an Android block, when to use test cases?

I am a little puzzled by testing in Android.

I know that there are 2 types of unit tests:

1. Local tests: running on a local JVM stored in app/src/test/java

2.Tool tests: running on Android system, saved in app/src/androidTest/java , annotated using @RunWith(AndroidJUnit4.class)

The above 2 classes do not extend TestCase and say that this is approach A in unit test.

And then I see test cases that are subclasses of TestCase, and they are placed next to the source code (in a separate package called xxx.test). Let them say that this is B.'s approach.

It seems to me that what is required when using TestCases (approach B), for example, confirmation of text in TextView can be achieved in the test tool + espresso (approach A).

So, I want to know when to use local tests / instrumental tests (approach A) and when to use subclasses of TestCases (approach B) ??

Thanks in advance ~~

PS: Using the Android testing platform , while this thread explains the use of different subclasses of TestCase, which is similar to the explanation of the subitems in my approach B, it does not answer my question.

+6
source share

All Articles