JUnit Launcher test ... getActivity is not returned

public class LauncherActivityTest extends ActivityInstrumentationTestCase2 <Launcher> {
private activation Launcher;

public LauncherActivityTest() { super("com.android.launcher.Launcher", Launcher.class); } @Override protected void setUp() throws Exception { super.setUp(); setActivityInitialTouchMode(true); } public void testLauncherApplication() { mActivity = getActivity(); assertTrue(mActivity != null); } 

}

add .... manifest.xml
<uses-library android: name = "android.test.runner" / ">
<android toolkit: targetPackage = "com.launcher.launcher" android: name = "android.test.InstrumentationTestRunner" / ">

I am trying to run the original Launcher JUnit test.
Why does the getActivity () function not return?
My phone only works with Launcher. but another application works and then runs the test.
ex) launch a phone application -> test: returning success
launch start only: wait state

Do you know, why? Help me please.

+6
source share
1 answer

You have a manifest file:

  <instrumentation android:targetPackage="com.android.example.spinner" android:name="android.test.InstrumentationTestRunner" /> 

And also check this:

 public class LauncherActivityTest extends ActivityInstrumentationTestCase2<ActivityToTest> 
0
source

Source: https://habr.com/ru/post/892302/


All Articles