You need a tearDown() method, and for each activity you start, keep a handle
to it.. which depends on which Test package you are using. Looks like you
are using a single activity, in which case you can use getActivity() for
your current activity.
So an example would be:
@Override
protected void tearDown() throws Exception{
getActivity().finish;
randomVariable = null;
if(otherRandomActivity() != null)
otherRandomActivity().finish()
....
....
super.tearDown();
}
See if that helps!
On Mon, Apr 20, 2009 at 1:44 PM, Julie Alexan <[email protected]> wrote:
>
> Hi, All! Using 'ddms' and repeatably clicking SysInfo -> Update from
> Device helped me find a memory leak. So we have 9 JUnit test cases
> spread amongst 4 files, and we run them in eclipse. After EACH test
> cases finishes, our application is exiting; and it restarts again for
> the next test case. So for now, that's 9 times our app is closing and
> restarting, which would be fine, except that each time it close it
> leaks memory so that there is less available for the next test. All
> we have for @before and @after is this:
>
> @Before
> public void setUp() {
> System.gc(); // <-------- TRIED TO SEE IF THIS WOULD HELP,
> BUT IT
> DIDN'T
> startActivity("com.yellowpages.android.ypmobile",
> "com.yellowpages.android.ypmobile.YPM");
> waitForStartup();
> }
>
> @After
> public void postTest() {
> if (wait_post_test) {
> waitFor("class.simpleName", "BASIC_TIMEOUT", timeout_in_ms);
> }
> }
>
> Questions:
> 1. What's the proper solution? Find a way to only start the app ONE
> time then run all tests? Or fix the leak?
> 2. To fix the leak, is there something we're missing/forgetting to do
> in the @After method?
> 3. As a quick fix, is there somewhere particular in the positron code
> that I can do a garbage collect() that might help?
>
> Any help is appreciated.
> Thanks,
>
> Julie
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---