Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connectedAndroidTest how to run specific tests

I am a QA with a start up company. My Developer setup Instrumentation tests in the Android Project. He also setup the Jenkins Jobs to run these tests in CI env.

This is the command given in "Tasks" field in Jenkins job under Build --> Invoke Gradle script. clean assembleDebug connectedAndroidTest testDebug

I would like to create my own Jenkins job to run different types of tests. Is there a way that I can filter my tests by just running "connectedAndroidTest" command? I tried using shell script like the following, but it didn't work. adb shell am instrument -w /

I am getting the following error message: [Execute Smoke Test Suite] $ /bin/bash -xe /var/folders/qr/vtm32_d56vz0hgwg5ppdbswc00007q/T/hudson1779650135635362469.sh + adb shell am instrument -w ' ' class com.draysonwireless.airmapandroid.rewards/BonusTest.java /var/folders/qr/vtm32_d56vz0hgwg5ppdbswc00007q/T/hudson1779650135635362469.sh: line 2: adb: command not found Build step 'Execute shell' marked build as failure Finished: FAILURE

like image 597
jellyBeans Avatar asked Apr 18 '16 15:04

jellyBeans


People also ask

How to run tests from gradle command line?

Use the command ./gradlew test to run all tests.

What are instrumented tests?

Note: Instrumented test, also known as instrumentation tests, are initialized in a special environment that gives them access to an instance of Instrumentation. This class provides access to the application context and APIs to manipulate the app under test and gives instrumented tests their name.


1 Answers

Seems that your jenkins user can't see android adb therefore build fails. Add adb to the system path or point it's exact location.

As to running specific tests via gradle command below is an example:

./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 can vary depending on the test flavour existence.

like image 193
denys Avatar answered Oct 20 '22 17:10

denys