Skip to content

Instantly share code, notes, and snippets.

@tir38
Last active February 5, 2020 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tir38/1266cbf745f0077b0bbb8e54bf255f8f to your computer and use it in GitHub Desktop.
Save tir38/1266cbf745f0077b0bbb8e54bf255f8f to your computer and use it in GitHub Desktop.
Android: Run instrumentation tests on a single class or single method
#!/bin/bash
if [ -z "$1" ]; then
echo "Must specify module (e.g. app)"
exit 1
fi
if [ -z "$2" ]; then
echo "Must specify build type, starting w/ capital letter (e.g. Debug, DebugFree, ReleasePaid)"
exit 1
fi
if [ -z "$3" ]; then
echo "Must specify package/class/test/regex. Examples:"
echo "* fully qualified class: com.example.MytestClass"
echo "* fully qualified method: com.example.MytestClass#myTest"
echo "* wildcard on package: com.example.*"
echo "* wildcard on class: MytestClass*"
echo "* wildcard on method: methodname*"
echo "(note: does not support leading wildcard e.g. *TestClass)"
exit 1
fi
echo ===============
echo Running $1:connected$2AndroidTest for: $3
echo ===============
./gradlew $1:connected$2AndroidTest -Pandroid.testInstrumentationRunnerArguments.tests_regex=$3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment