android - TestCase 类 junit.extensions.ExceptionTestCase 缺少没有参数或单个 String 参数的公共(public)构造函数

标签 android

上下文:Windows 7 操作系统,最新的 Android ADT IDE,robotium jar 文件,Android

查询:我创建了一个 testrobotium 类,它作为 android junit 执行,应该触发 AUT,即 android 应用程序。在将 testrobotium 类作为 android junit 执行时,我在 logcat 中收到以下错误:

01-24 12:17:44.708: I/TestGrouping(2235): TestCase class junit.extensions.ExceptionTestCase is missing a public constructor with no parameters or a single String parameter - skipping
01-24 12:17:44.790: I/TestRunner(2235): started: null(com.sap.esm.retail.test.InitialTest)

包含构造函数的 InitialTest 类的代码如下:

package com.sap.esm.retail.test;

import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.jayway.android.robotium.solo.Solo;
import com.sap.esm.retail.MobileRetailingActivity;
import com.sap.esm.retail.OrderSumaryActivity;
import com.sap.esm.retail.ProductDetailsActivity;
import com.sap.esm.retail.ShippingDetailsActivity;

import com.sap.esm.retail.R;

public class InitialTest extends
        ActivityInstrumentationTestCase2<MobileRetailingActivity> {

    public Solo solo;
    private TextView cartNo;
    private ImageView Img;
    private String actualTot;


    public InitialTest(String name) throws ClassNotFoundException {
        super(MobileRetailingActivity.class);
    }

    protected void setUp() throws Exception {
        super.setUp();
        solo = new Solo(getInstrumentation(),getActivity());
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }

...........

因此,我认为构造函数存在一些问题。

请帮忙。

最佳答案

你必须在你的构造函数中提供应用程序包,看这里: http://code.google.com/p/robotium/wiki/Getting_Started 它应该看起来像这样:

public InitialTest() {
     super("com.sap.esm.retail", MobileRetailingActivity.class);
}

关于android - TestCase 类 junit.extensions.ExceptionTestCase 缺少没有参数或单个 String 参数的公共(public)构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14501477/

相关文章:

Android启动画面与服务器通信

android - 在哪里放置更高分辨率的图像?

java - 致命异常 : main Unable to start activity ComponentInfo Caused by java. lang.NullPointerException

Android Gradle 3.0.0 - 为特定风格添加库依赖

android - 在 http 请求中将用户名和密码作为参数发送

android - exoplayer setPlayWhenReady() 为什么不工作?

android - 将现有 JAR 或 AAR 作为新项目模块导入

使用 Azure 通知中心的 Android 推送通知

android - 如何设置白天模式和夜间模式

java - 在应用程序中显示来自 EditTextPreference 的文本?