0

这是我使用robotium 测试android 计算器的示例测试项目。我想创建这个项目的 jar 文件,但是在创建它时,它显示如下错误:

"Error: Could not find or load main class TestMain".

我认为它显示了这个错误,因为其中没有主类,即它找不到“ public static void main(String args[])”。我应该怎么做才能克服这个问题?

package com.testcalculator;

import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;

@SuppressWarnings("unchecked")
public class TestCal extends ActivityInstrumentationTestCase2
{
    private static final String TARGET_PACKAGE_ID="com.calculator";
    private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME="com.calculator.Main";
    private static Class launcherActivityClass;
    static
    {
        try
        {
            launcherActivityClass=Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
        }
        catch (ClassNotFoundException e)
        {
            throw new RuntimeException(e);
        }
    }
    public TestCal()throws ClassNotFoundException
    {
        super(launcherActivityClass);
    }

    private Solo solo;

    @Override
    protected void setUp() throws Exception
    {
        solo = new Solo(getInstrumentation(),getActivity());
    }
    public void testDisplayBlackBox() 
    {
        solo.enterText(0, "10");

        solo.enterText(1, "20");

        solo.clickOnButton("Multiply");

        assertTrue(solo.searchText("200"));
    }
    @Override
    public void tearDown() throws Exception 
    {
        solo.finishOpenedActivities();
    }
}
4

0 回答 0