4

I am trying JUnit test but facing following issue.

When I select Android JUnit Test by right clicking on Project it shows following message

Test run failed: Instrumentation run failed due to 'Native crash'

and when I right click on TestApk.java and select Android JUnit Test, it shows

Test run failed: Instrumentation run failed due to java.lang.ClassNotFoundException

Two cases occurs

Here is my source code.

@SuppressWarnings("unchecked")
public class TestApk extends ActivityInstrumentationTestCase2 {

      private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "com.nhn.android.ndrive";
      private static Class launcherActivityClass;
      static {

          try {
              launcherActivityClass = Class
                .forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
          } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
          }
      }

      public TestApk() throws ClassNotFoundException {
          super(launcherActivityClass);
      }

      private Solo solo;

      @Override
      protected void setUp() throws Exception {
         super.setUp();
         solo = new Solo(getInstrumentation(), getActivity());
      }

      public void testDisplayBlackBox() {
         //Enter any integer/decimal value for first editfield, we are writing  10
         solo.clickOnWebElement(By.id("com.nhn.android.ndrive:id/actionbar_photo_left_button"));
         solo.clickOnWebElement(By.id("com.nhn.android.ndrive:id/gnb_group_layout"));
         //Enter any integer/decimal value for first editfield, we are writing  20

         solo.clickOnWebElement(By.id("com.nhn.android.ndrive:id/actionbar_open_drawer_button"));
         //Click on Multiply button
         solo.clickOnButton("com.nhn.android.ndrive:id/base_menu_task_open_button");

        //Verify that resultant of 10 x 20
        //assertTrue(solo.searchText("200"));
       }

       @Override
       public void tearDown() throws Exception {
            solo.finishOpenedActivities();
       }

}

but package name is not wrong.

how to solve this problem?

silwar
  • 6,470
  • 3
  • 46
  • 66

0 Answers0