I have an Android test project based on InstrumentationTestCase and using AndroidJUnitRunner.
I need to provide my project to another party but I don't want to provide the source code.
Currently I have two projects:
The Java project is currently starting the AndroidTestProject by programmatically running "gradlew connectedCheck".
Now I want to give both the installer and the test project to other people but I don't want to disclose the source code. So it would be the equivalent of creating the apk but for a test project.
So my two questions are:
I don't know if this matters so here goes: my project hierarchy is
Project
.gradle
.idea
app
build
src
androidTest
java
package
sub-packages and java files
main
AndroidManifest
app.iml
build-gradle
proguard-rules.pro
build
gradle
...
I am gonna change my complete answer! Never thought this would be this easy.
On the right side of the android studio there will be gradle window. Open it and refresh it once to see your current project in it.
In the tasks section, build subsection -> assemble and assemble test options will be there. Assemble for your normal apk and assemble test for your test apk. These will be generated in the app/build/output/apk folder.
As for running them programatically, use gradle tasks (command line function in there for ./gradlew test --continue ) which will run tests after the build or if u want to use java use it as here. Using C is always easy for shell commands ;)
Edit 2: as Ines have mentioned in the comments, to run the tests you could just use:
adb install name-of-the-apk.apk adb shell am instrument -w packageWithTest/android.support.test.runner.AndroidJUnitRunner
for more executions see here