Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android unit test, super deprecated, replacement?

The android unit testing documents say to test with junit like this

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

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

Their example uses Android 2.1 though.

My app is using Android 4.2 although is backwards compatible.

What has the super class been replaced with? How should my constructor be written

like image 744
CQM Avatar asked Dec 06 '25 04:12

CQM


1 Answers

You will need to use the call:

super (SpinnerActivity.class);

It's specified in the Android reference docs.

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

Use this instead.

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
like image 56
HyprGeek Avatar answered Dec 07 '25 18:12

HyprGeek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!