sangmingming / robotium

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

It cannot set timeout for one whole test case and testing is hanging up sometimes. #167

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

When we running near 100 test cases, sometimes the testing is hanging up, and 
it will not end.
It will block other left unexecuted test cases.
So we want to set timeout for test case.
If I choose the wrong way to set timeout for test case, could you tell me other 
good ways?

Original issue reported on code.google.com by derek110...@gmail.com on 28 Sep 2011 at 1:50

GoogleCodeExporter commented 9 years ago
Not a robotium issue. 

Original comment by renasr...@gmail.com on 28 Sep 2011 at 2:07