I am trying to test JUnit, but ran into the following problem.
When I select Android JUnit Test, by right-clicking on the project, it will display the following message
Test run failed: Toolkit failed due to "Native crash"
and when I right-click on TestApk.java and select Android JUnit Test, it shows
Test run failed: instrumentation failed due to java.lang.ClassNotFoundException
There are two cases
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() {
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"));
solo.clickOnWebElement(By.id("com.nhn.android.ndrive:id/actionbar_open_drawer_button"));
solo.clickOnButton("com.nhn.android.ndrive:id/base_menu_task_open_button");
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
}
}
but the package name is not wrong.
How to solve this problem?
source
share