java - Can't select Test class in Edit Configuration -


i have created espresso/uiautomator unit test. however, when try run it, android studio won't recognize it. button select testlogin.java greyed out. i'm using android studio 2.0 preview 5. edit configurations screenshot

package com.greenrobot.yesorno.test.testlogin  import android.support.test.rule.activitytestrule; import android.support.test.runner.androidjunit4; import android.test.suitebuilder.annotation.largetest;  import org.junit.rule; import org.junit.test; import org.junit1.runner.runwith; import android.support.test.espresso.*;   /**  * created andytriboletti on 1/15/16.  */ @runwith(androidjunit4.class) @largetest public class testlogin extends activityinstrumentationtestcase2<startactivity> {     public testlogin(class<startactivity> activityclass) {         super(activityclass);     }     private uidevice mdevice;      @rule     public activitytestrule<home> mactivityrule = new activitytestrule(home.class);      @test     public void testlogin() {         mdevice = uidevice.getinstance(instrumentationregistry.getinstrumentation());          // start home screen         mdevice.presshome();         onview(withtext("hello world!")).check(matches(isdisplayed()));          onview(withid(r.id.changetextbt)).perform(click());      } 

my build.gradle:

   buildscript {     repositories {         maven { url 'https://maven.fabric.io/public' }     }      dependencies {         classpath 'io.fabric.tools:gradle:1.+'     } } apply plugin: 'com.android.application' apply plugin: 'io.fabric'     android {     aaptoptions.setproperty("cruncherenabled", false)      sourcesets {          androidtest {             java.srcdirs = ['androidtest/java']         }     }      lintoptions {         // set true turn off analysis progress reporting lint         quiet true         // if true, stop gradle build if errors found         abortonerror false         // if true, report errors         ignorewarnings true     }      productflavors {         // actual application flavor         production {             minsdkversion 15         }         // test application flavor uiautomatior tests         mytest {             minsdkversion 18         }     }     compilesdkversion 23     buildtoolsversion "23.0.2"      defaultconfig {         applicationid "com.greenrobot.yesorno"         minsdkversion 15         targetsdkversion 22         multidexenabled = true         testinstrumentationrunner "android.support.test.runner.androidjunitrunner"     }      buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt'         }     }     packagingoptions {         exclude 'meta-inf/asl2.0'         exclude 'meta-inf/license'         exclude 'meta-inf/maven/com.google.guava/guava/pom.properties'         exclude 'meta-inf/maven/com.google.guava/guava/pom.xml'     } }  repositories {     mavencentral()     maven { url 'https://maven.fabric.io/public' } }  repositories {     maven { url "http://jzaccone.github.io/slidingmenu-aar" }  } repositories {     maven { url "http://dl.bintray.com/populov/maven" }  }    dependencies {     compile 'com.squareup.picasso:picasso:2.5.2'     compile 'com.android.support:multidex:1.0.1'     compile 'com.robbypond:mopub-android-sdk:3.9.0'     compile 'com.facebook.android:facebook-android-sdk:4.7.0'     compile 'com.jeremyfeinstein.slidingmenu:library:1.3@aar'     compile 'com.android.support:support-v4:23.1.1'     compile files('libs/flurryagent.jar')     compile files('libs/autobahn-android-0.5.2-snapshot.jar')     compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'     compile project(':viewpagerindicator')     compile files('libs/gcm.jar')     compile 'com.jakewharton.timber:timber:3.1.0'     compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {         transitive = true;     }     compile 'com.squareup.okhttp3:okhttp:3.0.1'       compile 'com.android.support:support-annotations:23.1.1'     compile 'com.google.guava:guava:18.0'      // testing-only dependencies     androidtestcompile 'com.android.support:support-annotations:23.1.1'     androidtestcompile 'com.android.support.test:runner:0.4.1'     androidtestcompile 'com.android.support.test:rules:0.4.1'     androidtestcompile 'com.android.support.test.espresso:espresso-core:2.2.1'     androidtestcompile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0' } 

edit: here's picture of android studio. android studio

edit2: enable test artifacts (unit testing , instrumentation test) enabled. it's enabled

add 1 more package name test that: com.greenrobot.yesorno.test. put testlogin test inside it. should solve problem.

also: activityinstrumentationtestcase2 deprecated , can't used activitytestrule. leave activitytestrule , remove extends part , constructor. i'd suggest add setup() method @before annotation , instantiate mdevice there, available each test you'll have in test class.

update: remove this, sync , clean:

 androidtest {      java.srcdirs = ['androidtest/java']  } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -