我是Robotium的新手。我在执行使用Robotium的测试用例时遇到问题“junit.framework.AssertionFailedError” 。测试场景正在检查后退按钮功能。这是我的代码
package com.example.test;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.EditText;
import com.jayway.android.robotium.solo.Solo;
import com.example.app.R;
import com.example.app.LoginActivity;
import com.example.app.AccountCardListActivity;
import com.example.app.ReceiptListActivity;
import com.example.app.WithdrawalListActivity;
public class Back_Concerto_425 extends ActivityInstrumentationTestCase2<LoginActivity>{
public Back_Concerto_425() {
super(LoginActivity.class);
// TODO Auto-generated constructor stub
}
private Solo solo;
protected void setUp() throws Exception
{
solo = new Solo(getInstrumentation(), getActivity());
}
public void testbackbutton()
{
solo.enterText(0, "username");
solo.enterText(1, "password");
solo.clickOnButton(0);
solo.waitForActivity("com.example.app.WithdrawalListActivity", 3000);
assertTrue(solo.searchText("WithdrawlListActivity"));
solo.clickOnButton("View Receipts");
solo.waitForActivity("com.example.app.ReceiptListActivity",3000);
assertTrue(solo.searchText("Receipts"));
solo.goBackToActivity("com.example.app.WithdrawalListActivity");
assertTrue(solo.searchButton("View Receipts"));
assertTrue(solo.searchButton("New withdrawal"));
}
public void tearDown() throws Exception
{
try
{
solo.finalize();
}
catch (Throwable e)
{
e.printStackTrace();
}
super.tearDown();
}
}
这是我的错误日志
[INFO] Start [15/16]: com.ncr.mobile.mcw.test.WithdrawlListActivityTest#testreceiptsbutton
[INFO] FAILURE:com.ncr.mobile.mcw.test.WithdrawlListActivityTest#testreceiptsbutton
[INFO] junit.framework.AssertionFailedError
at com.ncr.mobile.mcw.test.WithdrawlListActivityTest.testreceiptsbutton(WithdrawlListActivityTest.java:45)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)
如果我的代码有任何错误,请告诉我。