junit testing with gradle for an android project

前端 未结 5 815
青春惊慌失措
青春惊慌失措 2020-12-24 12:31

I am trying to get tests ( junit and robolectric ) working in an Android project but am totally stuck. My main problem is that all testing I found with gradle somehow pull i

5条回答
  •  爱一瞬间的悲伤
    2020-12-24 13:08

    This guide might help - http://www.slideshare.net/tobiaspreuss/how-to-setup-unit-testing-in-android-studio

    Latest gradle the test should be under androidTest dir

    Also in your gradle.build:

    dependencies {
         androidTestCompile 'junit:junit:4.+'
    }
    

    also add those under defaultConfig {

    testPackageName "test.java.foo"
    testInstrumentationRunner "android.test.InstrumentationTestRunner"
    

    }

提交回复
热议问题