No, this shouldn't happen. However, to debug this, try the following:
- make sure you define the startUp() method for each test case. In it,
do
myactivity = getActivity();
to store a handle to the activity under test.
- make sure you define the tearDown() method for each test case. In
it, do
myactivity.finish();
to shut down the activity.
This ensures that each test method runs with a new instance of the
activity under test.
It therefore ensures that each test case runs with a new instance of
the activity under test.
If you are depending on an activity "surviving" across tests, then
you're not really doing a unit test. Each test method should be self-
contained, except for dependencies that you inject. The place to set
up dependencies across all the tests in a test case is setUp(). The
place to set up dependencies for a particular test is in the test
method. Each test method should assume that a new instance of the
activity is running, with no other assumptions other than the "test
fixture" (the sum of dependencies set up in setUp() and in the test
method).
Test cases themselves are just a convenience for organizing tests. You
could, if you wanted, put all your tests into one test case.
On Mar 2, 6:18 pm, Mooncheol Yang <[email protected]> wrote:
> Hi All
>
> I made test codes using ActivityInstrumentationTestCase2
>
> when I execute test case one by one in Eclipse, it works well.
>
> but when I execute all test cases, it freezes after one test case is
> executed,
>
> i guess that in ActivityInstrumentationTestCase2, after each test Case
> is executed, Android Test Framework is designed to to kill activity
> and launch again, but after one test case is ended, it seems that
> Android test framework can't kill activity.
> so test is hanging...
>
> anyone like me?
> any reply will be helpful
>
> Thanks..
--
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