ConnectedAndroidTest how to run specific tests

I am a QA with a start-up company. My test setup is a developer in an Android project. He also configured Jenkins Jobs to run these tests in CI env.

This is the command specified in the Tasks field of Jenkins’s task in the Build β†’ Call Gradle script section. clean assembleDebug connectedAndroidTest testDebug

I would like to create my own Jenkins task to run various types of tests. Is there a way so that I can filter my tests just by running the "connectedAndroidTest" command? I tried using a shell script as follows, but that did not work. adb shell am instrument -w /

The following error message appears: [Run Smoke Test Suite] $ / bin / bash -xe / var / folders / qr / vtm32_d56vz0hgwg5ppdbswc00007q / T / hudson1779650135635362469.sh + adb shell am instrument -w '' class com.draysonwireless.airmard /BonusTest.java / var / folders / qr / vtm 32_d56vz0hgwg5ppdbswc00007q / T / hudson1779650135635362469.sh: line 2: adb command: not found Build the "Run the shell" step by marking the line as failed Finished: FAILURE

+7
android android-instrumentation espresso
source share
2 answers

It seems that your jenkins user cannot see adroid adb, so the build fails. Add adb to the system path or specify the exact location.

Regarding running specific tests with the gradle command below:

./gradlew app:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.android.testing.blueprint.ui.espresso.EspressoTest#testMethodName

Taken from here with my slight modification. Your connectedAndroidtest command may vary depending on your test taste.

+9
source share

This is the shell script I used in my Jenkins work:

 export PATH=$PATH:/Users/Shared/Jenkins/Library/Android/sdk/platform-tools adb shell am instrument -w -r -e debug false -e class com.company.project.test.SmokeTest com.company.project.debug.test/android.support.test.runner.AndroidJUnitRunner 

The folder structure should be like this: app β†’ src β†’ androidTest β†’ java β†’ com.company.project β†’ test β†’ TestClass

0
source share

All Articles