How do I keep my Android testing libraries separate from my application libraries in Android Studio? -
i have module dependencies set in build.gradle file:
dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:22.2.0' androidtestcompile filetree(dir: 'libs/test', include: ['*.jar']) } inside libs folder have libraries necessary building application. placed libraries necessary running tests in subfolder called "test"
this seems work code compiles, , can make module. when attempt run of tests, however, fails find test libraries attempted include. errors in gradle console point pieces of code don't show errors.
also, have tests set correctly, because can them run moving required jars libs folder , changing dependencies to:
dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:22.2.0' } but don't see point of androidtestcompile if it's not working. i'd rather not include these jar files in apk if don't have to.
if helps, i'm using android studio version 1.2.2 , gradle plugin version 1.2.3.
thanks in advance help.
see below example.
create tests folder parallel src folder. create test cases folder. if create folder path need make call this.(added code.)
dependencies { androidtestcompile files('libs/dexmaker-1.1.jar') androidtestcompile files('libs/org.mockito:mockito-core:3.9.5') androidtestompile files('espresso-1.0-snapshot-bundled.jar') } defaultconfig { testapplicationid "xxx.xx.abc" testinstrumentationrunner "com.google.android.apps.common.testing.testrunner.googleinstrumentationtestrunner" } sourcesets { main { manifest.srcfile 'androidmanifest.xml' java.srcdirs = ['src'] } // move tests tests/java, tests/res, etc... instrumenttest.setroot('tests') instrumenttest { java.srcdirs = ['tests/src'] } androidtest.setroot('tests') androidtest.java.srcdirs = ['tests/src']
Comments
Post a Comment