1 of 23

for Application testing and Continuous Integration

2 of 23

Antonin Fouques

+AntoninFouques

@CmoaToto

SLIDES

Florent Noël

@heb_dtc

3 of 23

4 of 23

Agenda

01

GMTool

04

Q&A

03

Jenkins

02

Gradle Plugin

00

Java API

5 of 23

Android Tests

Dedicated to Android instrumented testsIn Genymotion

All calls are blockingIn Genymotion

You can change the system stateDirectly from your Android tests

Lesser impact on app codeNo proxy or mock required

Java API

6 of 23

public class TestPhone extends ActivityInstrumentationTestCase2<SampleActivity> {

public void testSmsReception() {

//Avoid the test if not a Genymotion device

if (!GenymotionManager.isGenymotionDevice()) return;�

// Send an SMS containing ABC string

GenymotionManager.getGenymotionManager(context)

.getRadio()

.sendSms("123456", "ABC");

//Your tests

View view = getActivity().findViewById(R.id.new_sms_received);

assertEquals(view.getVisibility(), View.VISIBLE);

}

}

Test if Genymotion device

Send an SMS

Android Test

Test your app here!

7 of 23

Binocle

Java API showcaseBattery, GPS, Android ID, Radio, Network

OpensourceGenymobile/genymotion-binocle on GitHub

8 of 23

GMTool

The command line binary

9 of 23

GMTool

Genymotion command line toolManage, configure and interact with everything

Part of Genymotion binariesBundled into Genymotion

Requires premium licenses

Business or Indie

Description

10 of 23

GMTool

gmtool adminManage virtual devices

gmtool deviceInteract with a started virtual device

gmtool config

Configure Genymotion

gmtool license

Control the Genymotion license

Command line

11 of 23

Demo time !

12 of 23

Gradle Plugin

Automation from build script

13 of 23

Gradle Plugin

Control GenymotionFrom your build.gradle

Based on command line toolGMTool

Create & customize your devicesTemplate, screen size,

Flash, install, push, pull

Start the devices

Before your Gradle test task

Description

14 of 23

buildscript {

repositories {

jcenter()

}

dependencies {

classpath 'com.genymotion:plugin:1.0'

}

apply plugin: "genymotion"

genymotion.devices {

nexus5 {

template "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920"

}

"Nexus 7" {

template "Google Nexus 7 - 4.2.2 - API 17 - 800x1280"

}

}

Add the plugin repository

Apply the Genymotion Gradle plugin

Gradle Plugin

build.gradle

Define the target devices

And the dependency

15 of 23

"Nexus 10" {

template "Google Nexus 10 - 4.3 - API 18 - 2560x1600"

density "XHDPI"

width 800

height 600

virtualKeyboard true

flash "PATH_TO/test.zip"

install "PATH_TO/test.apk"

pushBefore ["PATH_TO/test.txt", "PATH_TO/test2.txt"]

pullAfter ["/system/build.prop":"PATH_TO/res/"]

logcat "PATH_TO/res/Nexus 10.logcat"

productFlavors "flavor1"

stopWhenFinish false

deleteWhenFinish false

...

}

Edit the device on the fly

Override /system/

Gradle Plugin

build.gradle

push/pull files

before/after tests

Install apps

Route logcat to a file

And more!

16 of 23

Demo time !

17 of 23

Continuous integration

with Jenkins

18 of 23

Continuous Integration

System

  • VT-x or AMD-V capable CPU
  • 400MB disk space
  • OpenGL 2.0
  • 2GB RAM
  • Linux, MacOS, Windows
  • NO virtualisation

X server REQUIRED

cannot run on a headless server

Genymotion

Requirements

19 of 23

Continuous Integration

Genymotion & GMTool

Install 2.5.0+ version

Gradle Plugin configuration

Follow the Gradle Plugin tutorial

Integration

20 of 23

Continuous Integration

Running a Jenkins Slave

over the network

Add the slave node

As usual (see Jenkins Wiki)

Export DISPLAY variable (Linux)

Set to “:0” usually

Set your project to use the slave

Restrict where this project can be run

21 of 23

Demo time !

22 of 23

Conclusion

GMToolUser Guide

Genymotion Gradle PluginTutorial

Genymotion + JenkinsBlog post

WebinarVideo

Resources

23 of 23

Q&A

It’s your turn!

SLIDES