我正在使用Robotium Recorder進行android whitebox測試。如果我把它放在兩個不同的文件中,我有兩個測試代碼可以正常運行。但是,如果我將相同的測試代碼放在不同功能的相同文件中,則只有第一種方法(test1)
運行,並且test2
變爲失敗。使用Robotium Recorder在同一文件中運行不同的測試腳本
package com.samsung.mdl.radio.test;
import com.samsung.mdl.radio.MainActivity;
import com.robotium.solo.*;
import android.test.ActivityInstrumentationTestCase2;
public class AddToMyStationsTest extends
ActivityInstrumentationTestCase2<MainActivity> {
private Solo solo;
public AddToMyStationsTest() {
super(MainActivity.class);
// TODO Auto-generated constructor stub
}
protected void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation());
getActivity();
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
public void test1() throws Exception {
solo.waitForActivity(com.samsung.mdl.radio.MainActivity.class, 2000);
assertTrue("com.samsung.mdl.radio.SplashActivity is not found!", solo.waitForActivity(com.samsung.mdl.radio.SplashActivity.class));
solo.clickOnView(solo.getView(com.samsung.mdl.radio.R.id.dialog_positive_button));
Timeout.setSmallTimeout(17313);
solo.sleep(6000);
// Click on ImageView
solo.clickOnView(solo.getView(com.samsung.mdl.radio.R.id.options_button));
// Click on Never Play Song
solo.clickOnView(solo.getView(com.samsung.mdl.radio.R.id.element_text, 1));
// Click on Undo
solo.clickOnView(solo.getView(com.samsung.mdl.radio.R.id.undo_button));
}
public void test2() throws Exception {
solo.waitForActivity(com.samsung.mdl.radio.MainActivity.class, 2000);
assertTrue("com.samsung.mdl.radio.SplashActivity is not found!", solo.waitForActivity(com.samsung.mdl.radio.SplashActivity.class));
solo.clickOnView(solo.getView(com.samsung.mdl.radio.R.id.dialog_positive_button));
Timeout.setSmallTimeout(17313);
solo.sleep(6000);
solo.clickOnView(solo.getView(com.samsung.mdl.radio.R.id.options_button));
solo.clickOnView(solo.getView(com.samsung.mdl.radio.R.id.element_text, 2));
}
}
那麼現在我該怎麼做。我做錯了什麼?可能嗎 ?
請指定在這裏失敗是什麼意思?第二種測試方法正在運行,其失敗或第二種測試方法根本沒有執行? –