Top Banner
16

Lecture on automation

Jul 18, 2015

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture on automation
Page 2: Lecture on automation

How to organize execution of tests

on real Android devices

Misha Beshkin. DevConfu 2. Jurmala May, 2014

Page 3: Lecture on automation

Agenda

● Little bit about me● A little about Nitro Nation and Creative Mobile● A lot about A.C.T.H.U.L.H.U● Qs&As

Page 4: Lecture on automation

Misha Beshkin

● Was born and raised in Daugavpils, Latvia

● Studied in Daugavpils University, Faculty of Humanities.

● Moved to Tallinn in December 2003● Worked for Symantec Estonia as QA engineer

● In 2013 changed for Creative Mobile

Page 5: Lecture on automation

Creative Mobile

Page 6: Lecture on automation

Nitro Nation

Page 7: Lecture on automation

A.C.T.H.U.L.H.U

© DreamLand Toys

Automation Controller. Tester's Hands Unloading LeadsHuman Unemployment

Page 8: Lecture on automation

How it looks like?

Page 9: Lecture on automation

What does it do?Download latest

orset apk

Uninstall preciously installed version

Install apk Collect logs

Run Activity

Save log for a device

Page 10: Lecture on automation

How devices are added?

String apkExe = "adb"; AndroidDebugBridge.initIfNeeded(false);AndroidDebugBridge adb = AndroidDebugBridge.createBridge(apkExe, true);if (adb == null) { System.err.println("Invalid ADB location."); System.exit(1);}

Init ADB

Prerequisites:● Android SDK● DDMS library● ADB binary

Page 11: Lecture on automation

How devices are added?

final List<IDevice> deviceList = new ArrayList<IDevice>();AndroidDebugBridge.addDeviceChangeListener(new AndroidDebugBridge.IDeviceChangeListener() {

@Override public void deviceChanged(IDevice device, int arg1) { // not implement }

@Override public void deviceConnected(IDevice device) {

System.out.println(String.format("%s connected", device.getSerialNumber())); Map<String, String> properties = null;

try { properties = getDeviceInformation(device); } catch (Exception e) { e.printStackTrace(); } if (properties!=null) { deviceList.add(device); } }

@Override public void deviceDisconnected(IDevice device) { System.out.println(String.format("%s disconnected", device.getSerialNumber()));

}});

Add devices to list

Page 12: Lecture on automation

Execute shell command

ShellOutputReceiver shellOutputReceiver= new ShellOutputReceiver("MemTotal");device.executeShellCommand("cat /proc/meminfo", shellOutputReceiver);String memory = shellOutputReceiver.toString();

Get RAM info

ShellOutputReceiver shellOutputReceiver= new ShellOutputReceiver("Processor");device.executeShellCommand("cat /proc/cpuinfo", shellOutputReceiver);String cpu = shellOutputReceiver.toString();

Get CPU info

ShellOutputReceiver shellOutputReceiver= new ShellOutputReceiver("GLES:");device.executeShellCommand("dumpsys", shellOutputReceiver);String gpu = shellOutputReceiver.toString();

Get GPU info

Page 13: Lecture on automation

ShellOutputReceiverpublic class ShellOutputReceiver implements IShellOutputReceiver { private String result; private int checkRunning = 0; private String grepPattern = "";

public ShellOutputReceiver(String grepPattern) { this.grepPattern = grepPattern; }

@Override public void addOutput(byte[] bytes, int i, int i2) { String result = ""; result = new String(bytes); String[] array = result.split("\r\n"); for (int i=0; i< array.length; i++) { if (array[i].contains(grepPattern)) { this.result = array[i]; break; } } }

@Override public void flush() { }

@Override public boolean isCancelled() { return false; }

@Override public String toString(){ return result; }}

Page 14: Lecture on automation

Show Time

Page 15: Lecture on automation

Questions & Answers

Page 16: Lecture on automation

Thank you for attention

http:// misha.beshkin.lvmail:// [email protected]

facebook:// beshkintwitter:// midbarphone:// +372-53454663