for Application testing and Continuous Integration
Antonin Fouques
+AntoninFouques
@CmoaToto
SLIDES
Florent Noël
@heb_dtc
Agenda
01
GMTool
04
Q&A
03
Jenkins
02
Gradle Plugin
00
Java API
Android Tests
Dedicated to Android instrumented tests�In Genymotion
All calls are blocking�In Genymotion
You can change the system state�Directly from your Android tests
Lesser impact on app code�No proxy or mock required
Java API
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!
Binocle
Java API showcase�Battery, GPS, Android ID, Radio, Network
Opensource�Genymobile/genymotion-binocle on GitHub
GMTool
The command line binary
GMTool
Genymotion command line tool�Manage, configure and interact with everything
Part of Genymotion binaries�Bundled into Genymotion
Requires premium licenses
Business or Indie
Description
GMTool
gmtool admin�Manage virtual devices
gmtool device�Interact with a started virtual device
gmtool config
Configure Genymotion
gmtool license
Control the Genymotion license
Command line
Demo time !
Gradle Plugin
Automation from build script
Gradle Plugin
Control Genymotion�From your build.gradle
Based on command line tool�GMTool
Create & customize your devices�Template, screen size,
Flash, install, push, pull
Start the devices
Before your Gradle test task
Description
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
"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!
Demo time !
Continuous integration
with Jenkins
Continuous Integration
System
X server REQUIRED
cannot run on a headless server
Genymotion
Requirements
Continuous Integration
Genymotion & GMTool
Install 2.5.0+ version
Gradle Plugin configuration
Follow the Gradle Plugin tutorial
Integration
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
Demo time !
Conclusion
Resources
Q&A
It’s your turn!
SLIDES