sangmingming / robotium

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

Run first test method again in second test method, even though solo is finalized and activity is finished. #165

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. setUp() method:
super.setUp();
this.activity = this.getActivity();
this.solo = new Solo(getInstrumentation(), this.activity);

tearDown() method:
try {
this.solo.finalize();
} catch (Throwable e) {
e.printStackTrace();
}
this.activity.finish();
super.tearDown();

testMethod1():
Thread t = new Thread() {
public void run() {
//It will be timed out.
doSomeTestOperations();
}
};
t.start();
t.join(20);
fail("Time out");

testMethod2():
doSomeTestOperations();

2. Make testMethod1() time out, then check testMethod2() can be executed well 
or not.

3. Run test for this whole class.

What is the expected output? 
testMethod1 is failed by time out.
testMethod2 is passed successfully.

What do you see instead?
testMethod1 is failed by time out.
Running testMethod1 content again in testMethod2, then get NullPointerException.

What version of the product are you using? On what operating system?
Robotium2.2
Android2.2

Please provide any additional information below.
After executing testMethod1, it is really done tearDown().
So the solo is finalized and activity is finished.
That means testMethod1 is completed done.
Why testMethod1 is executed again in testMethod2?

NullPointerException details:
java.lang.NullPointerException
E/AndroidRuntime( 2661):        at 
com.example.test.DemoTest$1.run(DemoTest.java:99)
W/ActivityManager(  306): Error in app com.example running instrumentation 
ComponentInfo{com.example.test/android.test.InstrumentationTestRunner}:
W/ActivityManager(  306):   java.lang.NullPointerException
W/ActivityManager(  306):   java.lang.NullPointerException
I/ActivityManager(  306): Force stopping package com.example uid=10118

Original issue reported on code.google.com by derek110...@gmail.com on 26 Sep 2011 at 3:22

GoogleCodeExporter commented 9 years ago
Robotium does not support being run concurrently in different threads.

Original comment by renasr...@gmail.com on 26 Sep 2011 at 6:55

GoogleCodeExporter commented 9 years ago
Thanks a lot.

In fact, what I want to do is set time out for test case.
So I want to check testMethod2 can be executed well after testMethod1 timed out.

Now, I think the root cause is that thread is not closed in testMethod1, then 
it effects testMethod2, am I right?

I tried to use method interrupt to close thread, but no help.
Is there any other ways to close thread?

Thank you very much.

Original comment by derek110...@gmail.com on 26 Sep 2011 at 8:48