ertionFailedError同时测试后退按钮在Androi

ertionFailedError同时测试后退按钮在Androi

本文介绍了junit.framework.AssertionFailedError同时测试后退按钮在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来Robotium.I'm面临的一个问题junit.framework.AssertionFailedError在执行其使用Robotium.Test场景测试用例检查后退按钮functionality.here是我的code

i am new to Robotium.I'm facing an issue "junit.framework.AssertionFailedError" while executing the test case which using Robotium.Test scenario is checking Back button functionality.here's my code

    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)

请让我知道如果我在code的任何错误。

Please let me know if there is any mistake in my code.

推荐答案

在我的一个朋友面临同样的问题,他通过给超时时间解决,类似的,你没有提到的超时时间waitactivity方法或只使用 WaitActivity 方法,无需超时参数

once one of my friend faced the same problem he resolved by giving timeout period,similarly you haven't mentioned timeout period in waitactivity method or by just using WaitActivity method without timeout argument.

希望它可以帮助

这篇关于junit.framework.AssertionFailedError同时测试后退按钮在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 12:04