http://i-miss-erin.blogspot.com/2010/04/android-cts-compatibility-test-suite.html
我是按照上面链接中提到的说明做的,
但是我对SimpleCalculator应用程序的源代码有一些错误。
我编写了一个SimpleCalculator应用程序,并为SimpleCalculator应用程序编写了测试用例。
然后我添加了我的测试代码,如上所述,但我在哪里添加我的SimpleCalculator应用程序源代码?
在没有添加SimpleCalculator应用程序源代码的情况下,我尝试执行make cts
,但它给了我一些错误。
我的测试程序是:
package com.example.SimpleCalculator.test;
import android.test.ActivityInstrumentationTestCase2;
import android.text.method.KeyListener;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.example.SimpleCalculator.Calculator;
public class SimpleCalculatorTest extends
ActivityInstrumentationTestCase2<Calculator> {
private Calculator mActivity;
private EditText myEditText;
private Button b1,b2;
int operand1=0,operand2=0;char operator;
public SimpleCalculatorTest(){
super("com.example.SimpleCalculator",Calculator.class);
}
@Override
protected void setUp() throws Exception{
super.setUp();
mActivity=this.getActivity();
myEditText=(EditText)mActivity.findViewById(com.example.SimpleCalculator.R.id.editText1);
b1=(Button)mActivity.findViewById(com.example.SimpleCalculator.R.id.digit1_button);
b2=(Button)mActivity.findViewById(com.example.SimpleCalculator.R.id.digit2_button);
}
/*public void testPressButton1()
{
System.out.println(operand1);
System.out.println(operand2);
assertEquals(1,Integer.parseInt((String)b1.getText()));
}*/
public void testPressButton2()
{
//Calculator cal=new Calculator();
//b1.setOnClickListener((OnClickListener) cal.b1);
//System.out.println(Integer.parseInt((String)b2.getText()));
//System.out.println(Integer.parseInt((String)b1.getText()));
assertEquals(2,Integer.parseInt((String)b2.getText()));
}
public void testcompute(){
Calculator cal=new Calculator();
int expectres=cal.compute(2,9,'+');
System.out.println(expectres);
assertEquals(11,expectres);
int expectres1=cal.compute(2,9,'*');
System.out.println(expectres1);
assertEquals(18,expectres1);
}
}
我的错误消息是:
target Java: SimpleCalculatorTests (out/debug/target/common/obj/APPS/SimpleCalculatorTests_intermediates/classes)
cts/tests/tests/SimpleCalculator1/src/com/example/SimpleCalculator/test/SimpleCalculatorTest.java:9: cannot find symbol
symbol : class Calculator
location: package com.example.SimpleCalculator
import com.example.SimpleCalculator.Calculator;
^
cts/tests/tests/SimpleCalculator1/src/com/example/SimpleCalculator/test/SimpleCalculatorTest.java:12: cannot find symbol
symbol: class Calculator
ActivityInstrumentationTestCase2<Calculator> {
^
cts/tests/tests/SimpleCalculator1/src/com/example/SimpleCalculator/test/SimpleCalculatorTest.java:13: cannot find symbol
symbol : class Calculator
location: class com.example.SimpleCalculator.test.SimpleCalculatorTest
private Calculator mActivity;
^
cts/tests/tests/SimpleCalculator1/src/com/example/SimpleCalculator/test/SimpleCalculatorTest.java:20: cannot find symbol
symbol : class Calculator
location: class com.example.SimpleCalculator.test.SimpleCalculatorTest
super("com.example.SimpleCalculator",Calculator.class);
^