0

嘿,

我是 Android 测试的新手。我尝试编写使用editText 将两个数字相乘的测试。它似乎没有运行并且在模拟器上没有显示任何内容。我的测试代码如下

import android.test.ActivityInstrumentationTestCase2;

import com.example.calculator.MainActivity;
import com.jayway.android.robotium.solo.Solo;

public class MathValidation extends ActivityInstrumentationTestCase2<MainActivity> {

    private Solo solo;
    public MathValidation() {
        super(MainActivity.class);
    }

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

    protected void tearDown() throws Exception {
        solo.finishOpenedActivities();
    }
    public void Test() throws Exception{
        solo.assertCurrentActivity("wrong activity", MainActivity.class);
        solo.enterText(0, String.valueOf("10"));
            solo.enterText(1,String.valueOf("30"));
        solo.clickOnButton("Multiply");
        assertTrue(solo.searchText("300"));


    }

这是我的日志猫

01-15 16:23:27.832: E/Trace(1190): error opening trace file: No such file or directory (2)
01-15 16:23:27.832: W/Trace(1190): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:27.832: W/Trace(1190): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:27.832: W/Trace(1190): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:28.322: D/dalvikvm(1190): GC_CONCURRENT freed 331K, 15% free 2565K/3012K, paused 72ms+101ms, total 265ms
01-15 16:23:28.322: D/dalvikvm(1190): WAIT_FOR_CONCURRENT_GC blocked 12ms
01-15 16:23:28.713: D/dalvikvm(1190): GC_CONCURRENT freed 484K, 20% free 2540K/3144K, paused 73ms+85ms, total 215ms
01-15 16:23:28.862: W/Trace(1190): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:28.862: W/dalvikvm(1190): method Landroid/test/InstrumentationTestRunner$StringResultPrinter;.print incorrectly overrides package-private method with same name in Ljunit/textui/ResultPrinter;
01-15 16:23:31.202: E/Trace(1216): error opening trace file: No such file or directory (2)
01-15 16:23:31.212: W/Trace(1216): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:31.212: W/Trace(1216): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:31.212: W/Trace(1216): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:31.772: D/dalvikvm(1216): GC_CONCURRENT freed 334K, 16% free 2558K/3012K, paused 72ms+85ms, total 246ms
01-15 16:23:32.182: D/dalvikvm(1216): GC_CONCURRENT freed 491K, 18% free 2571K/3124K, paused 72ms+73ms, total 220ms
01-15 16:23:32.332: W/Trace(1216): Unexpected value from nativeGetEnabledTags: 0
01-15 16:23:32.332: W/dalvikvm(1216): method Landroid/test/InstrumentationTestRunner$StringResultPrinter;.print incorrectly overrides package-private method with same name in Ljunit/textui/ResultPrinter;
4

2 回答 2

0

所有这些显示的是代码,而不是您实际运行测试的方式。您是从 Eclipse 还是从命令行运行它?无论如何,这将有助于查看您正在遵循的确切步骤。

另外,Solo 是一项活动吗?

于 2013-01-15T20:36:36.407 回答
0

在大多数测试框架中,测试方法的名称必须以test. 方法名称区分大小写,因此问题是您的方法被调用Test()而不是test(). 这就是它没有运行的原因。

Java 中的标准编码约定使用以小写字母开头的方法名称。此外,您通常希望为您的测试提供更具描述性的名称,例如testMultiply().

于 2013-11-06T04:41:44.710 回答