Android系统单元测试方法(22)
发表于:2011-06-30来源:未知作者:领测软件测试网采编点击数:
标签:
三、被测试的Activity代码 Java代码 # package cc.androidos.activity; # import android.app.Activity; # import android.os.Bundle; # import android.widget.Button; # public class NewActivity exten
三、被测试的Activity代码
-
# package cc.androidos.activity;
-
# import android.app.Activity;
-
# import android.os.Bundle;
-
# import android.widget.Button;
-
# public class NewActivity extends Activity {
-
#
-
# @Override
-
# public void onCreate(Bundle savedInstanceState) {
-
# super.onCreate(savedInstanceState);
-
# setContentView(R.layout.main);
-
# }
-
# public int add(int a , int b){
-
# return a+b;
-
# }
-
# }
# package cc.androidos.activity;
# import android.app.Activity;
# import android.os.Bundle;
# import android.widget.Button;
# public class NewActivity extends Activity {
# /** Called when the activity is first created. */
# @Override
# public void onCreate(Bundle savedInstanceState) {
# super.onCreate(savedInstanceState);
# setContentView(R.layout.main);
# }
# public int add(int a , int b){
# return a+b;
# }
# }
四、测试NewActivity代码,这里要继承ActivityInstrumentationTestCase2,ActivityInstrumentationTestCase2是TestCase的子类
-
* package cc.andoridos.activity.test;
-
* import cc.androidos.activity.NewActivity;
-
* import cc.androidos.activity.R;
-
* import android.test.ActivityInstrumentationTestCase2;
-
* import android.util.Log;
-
* import android.view.KeyEvent;
-
* import android.widget.Button;
原文转自:http://www.ltesting.net