Hi,
I believe the order is determined by TestSuiteBuilder and in fact it
partially sorts according to fully qualified name.
I just posted a blog entry that mentions it partially:
http://blogprogramistyandroid.blogspot.com/2011/02/randomizing-order-of-tests.html
You can take a look at the RandomizingTestRunner.
I think you can:
1. Put the test(s) in order you want by sorting them in onStart()
a) with hardcoded values in TestRunner (not very convenient I guess)
b) with a variable passed to a bundle and collected onCreate() (take a
look at
http://www.google.com/codesearch/p?hl=en#5oTG8Wvrixk/trunk/android-x86/frameworks/base/test-runner/android/test/InstrumentationTestRunner.java&q=InstrumentationTestRunner%20onCreate&l=259)
and pass argument adb shell am instrument -e order "test1,test3,test4'
class/testrunner
(not sure how to launch in eclipse)
2. I believe you can write test as
test1() {
internal_test1()
internal_test2()
internal_test3()
}
so you know the order will be 1,2,3 but if 2 fails the 3rd is not
executed. I am not sure if you can live with that
3. You can use suite() method;
public static final Test suite() {
TestSuite testSuite = new TestSuite();
testSuite.addTest(new MyTestCase("test1"));
testSuite.addTest(new MyTestCase("test2"));
return testSuite;
}
your test case musts have a no-arg constructor and a constructor with
string parameter that looks like this
public MyTestCase(String name) {
setName(name);
}
The last method seem to be most convenient.
HTH