Trial tests and control tests of androids on Jenkins (Gradle)

In my androidTest folder, I have units and instrumental tests.

I am trying to run these tests on my local Jenkins.

I successfully configured my project with Jenkins, and I also created an emulator for instrumentation tests.

So far, all the resources that I have seen are focused only on ant and earlier versions of Gradle. The syntax for writing tasks has changed a bit in the current version, and I'm confused about this.

Here is my build.gradle file:

apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "myPackageName" minSdkVersion 16 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.google.android.gms:play-services:6.5.87' } 
+8
source share
3 answers

You can write jenkis script as follows:

 stage('Build & Install') { //Build the apk and the test apk which will run the tests on the apk sh 'chmod +x gradlew && ./gradlew --no-daemon --stacktrace clean :app:assembleDevDebug :app:assembleDevDebugAndroidTest' } stage('Tests') { //Start all the existing tests in the test package sh './gradlew --no-daemon --debug :app:connectedDevDebugAndroidTest' } 

This should install apk and test apk on the device and run the test cases in the apk test upon installation.

Here I gave DevDebug since I have a taste constant called Dev and the build type is Debug. If you do not have them, you do not use them.

0
source

Create a job in junkins and (configure the adb path) add this command to create steps as a shell execution command or as a bat cmd window

 $ adb shell am instrument -w com.xyz.abc.test/android.test.InstrumentationTestRunner 

PS: - For better automation, use a robotium and a spoon with junkins, you can automate everything, you click commit on git and you will get test results in your inbox, which will be cool.

Edit

Running tests using a spoon

Add these commands to create steps.

 ./gradlew assembleDebugAndroidTest ./gradlew assembleDebug 

specify the path debug-build.apk and test-unaligned.apk the path in the correct spoon

  java -jar C:\Users\Shivam\Downloads\spoon-runner-1.1.1-jar-with-dependencies.jar --apk C:\Users\Shivam\Downloads\SpoonAndRobotiumTest\app\build\outputs\ apk\app-debug.apk --testapk C:\Users\Shivam\Downloads\SpoonAndRobotiumTest\ app\build\outputs\apk\app-debug androidTest-unaligned.apk --sdk E:\sdk 
-1
source

You must first install the Gradle plugin on your Jenkins-CI installation. You can find it at http: // yourhost / jenkins / pluginManager /

To continue the integration, you can take a look at this presentation , especially on the last slides.

-2
source

Source: https://habr.com/ru/post/1211606/


All Articles