First of all, yes, you can organize multiple "tests" into one test
method, but that's not the accepted way of doing unit/functional
testing. That's why you should use
ActivityInstrumentationTestCase2(AITC2) in *most* cases to do unit/
functional testing of multiple methods in an Activity or multiple
pathways through it. Having a clean fixture (from setUp() and
tearDown()) for every test you do is the only safe way to ensure
you're testing what you *think* you're testing.

As you say, you definitely need to use if you expect your Activity to
handle different Intents. You can only set up the Intent in advance if
you use AITC2.

As you say, SingleLaunchActivityTestCase(SLATC) is primarily for
situations where you want to simulate a non-standard mode. The three
non-standard modes share a characteristic that, depending on the
circumstances, there will only be a single instance of the Activity.
SLATC forces a single instance for multiple test methods. You can use
it to either do multiple different tests on the same instance, or run
the same test multiple times.

Hope this helps.

elk elk elk

On Jan 26, 10:04 pm, Peter12 <[email protected]> wrote:
> I have studied the android test framework recently and have some
> questions about the differences between
> ActivityInstrumentationTestCase2 and SingleLaunchActivityTestCase test
> case classes.
> I know the difference in definition.
> ActivityInstrumentationTestCase2 class is used in functional testing
> and can let developer to mock intent. This is an important feature for
> activity which may deal with multiple intents.
> SingleLaunchActivityTestCase class is for testing an activity which
> does not change from test to test because it set up and tear down once
> and can test the activity handles multiple calls correctly.
> However, in my opinion, we also can organize multiple calls into one
> method and use ActivityInstrumentationTestCase2 class for this kind of
> test.
> Does anyone know about some scenarios which
> SingleLaunchActivityTestCase should adopt rather than
> ActivityInstrumentationTestCase2?
> By the way, in android Dev document, it said that
> “SingleLaunchActivityTestCase test case is useful for testing an
> activity that runs in a mode other than standard. “, which means we
> can use it in the other modes such as singleTop, singleTask, and
> singleInstance.
> Why is SingleLaunchActivityTestCase suitable for these three modes? Is
> it because SingleLaunchActivityTestCase class launches activity once
> so it can simulate these modes?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to