testing - Sharing code between Android Instrumentation Tests and Unit Tests in Android Studio -
it possible share code between 2 test modes in android studio? have set of mock utils class's need access in both of test modes.
finally found solution (workaround) blog post dan lew (http://blog.danlew.net/2015/11/02/sharing-code-between-unit-tests-and-instrumentation-tests-on-android/).
the solution i've come leverage source sets define common code. first, put shared test code src/sharedtest/java1 .
android { sourcesets { string sharedtestdir = 'src/sharedtest/java' test { java.srcdir sharedtestdir } androidtest { java.srcdir sharedtestdir } } } what it's doing above adding shared code directory both test , androidtest source sets. now, in addition default java sources, they'll include shared code.
Comments
Post a Comment