0

我有一个想要自动化的 Android 项目。

我为它创建了一个 Robotium 项目,这里有一个 TestCase:

package com.nu.art.software.cyborg.automation.test;


import android.app.Instrumentation;
import android.content.Context;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.Smoke;

import com.nu.art.software.cyborg.automation.core.AutomationManager;
import com.nu.art.software.cyborg.core.ApplicationLauncher;
import com.nu.art.software.cyborg.log.Log;
import com.nu.art.software.cyborg.log.Logger;
import com.nu.art.software.cyborg.modules.automation.AutomationScenario;
import com.nu.art.software.rexml.core.ReXML;


public class TestCase
        extends ActivityInstrumentationTestCase2<ApplicationLauncher>
        implements Logger {

    private AutomationScenario automationScenario;

    private Context context;

    private Context targetContext;

    protected AutomationManager manager;

    protected final String TAG = getClass().getSimpleName();

    public TestCase() {
        super(ApplicationLauncher.class);
    }

    @Override
    public final void setUp()
            throws Exception {
        Instrumentation instrumentation = getInstrumentation();
        context = instrumentation.getContext();
        targetContext = instrumentation.getTargetContext();
        automationScenario = ReXML.getSystemReXML().deserialize(AutomationScenario.class, context.getAssets().open("user_scenario.xml"));
        manager = new AutomationManager();
        manager.setInstrumentation(instrumentation);
        manager.init();
    }

    @Smoke
//  @SmallTest
    public void runScenario()
            throws Exception {
        try {
            manager.executeScenario(automationScenario);
        } catch (Exception e) {
            logError(e);
            throw e;
        }
    }

/**  Some log methods  **/
}

清单中定义的项目包与TastCase所在的包匹配:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nu.art.software.cyborg.automation.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="7" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <uses-library android:name="android.test.runner" />
    </application>

    <instrumentation
        android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="com.nu.art.software.android.services" />

</manifest>

我确定它无法识别测试,因为:

在此处输入图像描述

有什么我想念的吗?

提前致谢,

亚当。

4

1 回答 1

2

您的测试用例需要从测试开始。示例是 testRunScenario()。

于 2012-04-20T05:35:03.723 回答