I would test a lot of applications with one Test application. Currently I use Robotium, this is my code (the sample of Robotium) :
public class NotePadTest extends ActivityInstrumentationTestCase2<NotesList>{
private Solo solo;
private ArrayList<String> mesActivites = new ArrayList<String>();
public NotePadTest() {
super(NotesList.class);
}
@Override
public void setUp() throws Exception {
//setUp() is run before a test case is started.
//This is where the solo object is created.
solo = new Solo(getInstrumentation(), getActivity());
InputStream instream = null;
try {
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"activity.txt");
instream = new FileInputStream(file);
if (instream != null) {
InputStreamReader inputreader = new InputStreamReader(instream);
BufferedReader buffreader = new BufferedReader(inputreader);
String line;
do {
line = buffreader.readLine();
mesActivites.add(line);
} while (line != null);
}
} catch (Exception ex) {
} finally {
instream.close();
}
}
@Override
public void tearDown() throws Exception {
//tearDown() is run after a test case has finished.
//finishOpenedActivities() will finish all the activities that have been opened during the test execution.
solo.finishOpenedActivities();
}
public void testClasse() throws Exception {
for(int i=0;i<mesActivites.size();i++){
System.out.println(mesActivites.get(i));
solo.waitForActivity(mesActivites.get(i));
}
}
I have try to load the package name into a textfile but it doesn't work.. My activity.txt contain for example :
com.example.application.MyActivity
I would write in the same test application every test method for my applications..
For example :
I would like test MyBluetooth.class, MyWifi.class, MyGSM.class in the same Test Application but each class is in different package.
How I can process ?
Aucun commentaire:
Enregistrer un commentaire