xiaofans / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Can not running the two testcase in one Class #378

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
The Class have two TestCase,and I run the Class by the Android Junit test.
When it run the frist TestCase finished,but the app can not be closed,and Case2 
didn't start.

What is the expected output? What do you see instead?
I have debug the code.
when the Case1 finished it call the "tearDown()" can not close the app.And next 
call the "setUp()" cannot start app.
I check the code,didn't found any question,so why?

What version of the product are you using? On what operating system?
The version:
robotium-solo-3.6
jdk1.6.0_38
android ADT 21.0.0.v2012010310015

Please provide any additional information below.
The code:

    public void setUp() throws Exception {
        solo = new Solo( getInstrumentation(), getActivity() );
    }

    public void tearDown() throws Exception {
        try {
            solo.finalize();
        } catch ( Throwable e ) {
            e.printStackTrace();
        }
        getActivity().finish();
        super.tearDown();

    public void test1(){
        solo.sleep(2000);
        Log.d(TAG,"test1  runing");
    }
    public void test2(){
        solo.sleep(2000);
        Log.d(TAG,"test2  runing");
    }

Original issue reported on code.google.com by shenlian...@126.com on 11 Jan 2013 at 3:20

GoogleCodeExporter commented 9 years ago
Use solo.finishOpenedActivities() in your teardown. 

Original comment by renasr...@gmail.com on 11 Jan 2013 at 3:23

GoogleCodeExporter commented 9 years ago
I have try the finishOpenedActivities(),but its crash.
The code:
    public void tearDown() throws Exception {
        solo.finishOpenedActivities();
    }

The log:
[2013-01-15 10:41:46 - imo_test] Sending test information to Eclipse
[2013-01-15 10:41:50 - imo_test] Test run failed: Instrumentation run failed 
due to 'Process crashed.'
[2013-01-15 10:41:50 - imo_test] Test run finished

Original comment by shenlian...@126.com on 15 Jan 2013 at 2:45