Android单元测试,超级弃用,更换?

CQM*_*CQM 3 junit android unit-testing

android单元测试文件说用junit测试这样

public SpinnerActivityTest() {
      super("com.android.example.spinner", SpinnerActivity.class);
} // end of SpinnerActivityTest constructor definition
Run Code Online (Sandbox Code Playgroud)

http://developer.android.com/tools/testing/activity_test.html#InstallCompletedTestApp

他们的例子使用的是Android 2.1.

我的应用程序使用Android 4.2,虽然向后兼容.

什么超级班被取代?应该如何编写我的构造函数

小智 5

你需要使用这个电话:

super (SpinnerActivity.class);
Run Code Online (Sandbox Code Playgroud)

它在Android参考文档中指定.

ActivityInstrumentationTestCase2(String pkg, Class<T> activityClass)
This constructor was deprecated in API level 8. use ActivityInstrumentationTestCase2(Class) instead
Run Code Online (Sandbox Code Playgroud)

请改用它.

ActivityInstrumentationTestCase2(Class<T> activityClass)
Creates an ActivityInstrumentationTestCase2.

Parameters
activityClass   The activity to test. This must be a class in the instrumentation targetPackage specified in the AndroidManifest.xml
Run Code Online (Sandbox Code Playgroud)