我一直在尝试使用ActivityUnitTestCase
. 我的计算器应用程序的代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_page);
disp = (TextView) findViewById(R.id.disp);
n1 = (EditText) findViewById(R.id.n1);
n2 = (EditText) findViewById(R.id.n2);
calc = (Button) findViewById(R.id.calc);
calc.setOnClickListener(this);
}
public void onClick(View v) {
double num1 = Double.valueOf(n1.getText().toString());
double num2 = Double.valueOf(n2.getText().toString());
Intent in = new Intent(this,CalcActivity.class);
in.putExtra("num1",num1);
in.putExtra("num2", num2);
startActivity(in);
}
我希望能够对这两个数字执行一些操作,然后通过意图发送。我的问题是,您如何在单元测试期间检查传出意图的内容?