Test run failed: Test run failed to complete. Expected 1 tests, received 0

后端 未结 8 1837
长情又很酷
长情又很酷 2021-01-11 10:28

I tried starting a JUnit test (robotium) for my app:

public class MainTest extends ActivityInstrumentationTestCase2 {
    private Solo so         


        
8条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 11:18

    The problem is in your call at

    super("nix.android.contact", MainActivity.class);
    

    In my code I have

    super("nix.android.contact", Class.forName("nix.android.contact.MainActivity"));
    

    I've also done it this way without have to name the Generic for the ActivityInstrumentationTestCase 2

    public class TestApk extends ActivityInstrumentationTestCase2 {
    
        private static final String TARGET_PACKAGE_ID = "nix.android.contact";
        private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "nix.android.contact.MainActivity";
    
        private static Class launcherActivityClass;
        static{
                try {
                        launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
                } catch (ClassNotFoundException e) {
                        throw new RuntimeException(e);
                }
        }
    
        @SuppressWarnings("unchecked")
        public TestApk() throws ClassNotFoundException {
                super(TARGET_PACKAGE_ID, launcherActivityClass);
        }
    

提交回复
热议问题