35
Property of Gorilla Logic. Confidential. Kyle Balogh, Gorilla Logic, Inc. FoneMonkey for iOS

FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

Property of Gorilla Logic. Confidential.

Kyle Balogh, Gorilla Logic, Inc.

FoneMonkey for iOS

Page 2: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

2 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Who am I and why am I here?

• Owner of the FoneMonkey for iOS open source

project

– Previously developed complete iOS solutions for clients

while finishing college

• Manage FoneMonkey for iOS forum

Page 3: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

3 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey

• What is FoneMonkey and why is it cool?

• How can you make FoneMonkey be your

very own personal test monkey?

• What is the future of the monkey?

Page 4: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

4 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

The FoneMonkey Open Source Project

• Project created and governed by Gorilla Logic

• Source code repository, compiled binaries, and forums

hosted at www.gorillalogic.com/fonemonkey

• GPL (“Copy Left”)

• More than 1,000 registered downloaders

• New features prioritized according to feedback from

user community

• Code contributions from community are welcome!

Page 5: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

5 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Monkey See, Monkey Do

• Records and plays back “higher-level” events

– Does NOT record “Touch Screen 150,200”

– Records “commands” in the context of components

• Touch UIButton “OK”

• Touch “OK”

• Slide UISlider 75

• Drag MyCanvas 20, 30 , 20, 50

• Type “First Name” Fred

• Also records and plays device Shake and Orientation

Change

• Doesn’t yet handle multitouch gestures • Coming Soon!

Page 6: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

6 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

You link FoneMonkey into

your app

• Linking FoneMonkey adds the

FoneMonkey console to your

app, and enables recording and

playback

• Console “drops down”

after inactivity timeout

Page 7: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

7 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey Project Setup

1. Duplicate your app build target to create a

FoneMonkey testing target

Page 8: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

8 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey Project Setup

2. Add FoneMonkey to your Project

Page 9: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

9 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey Project Setup

3. Add FoneMonkey to your Testing Target

Page 10: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

10 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey Project Setup

4. Add –all_load linker flag

Page 11: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

11 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey Project Setup

5. Add QuartzCore and libxml required by FoneMonkey

to projectz

Page 12: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

12 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey Project Setup

6. Add /Developer/Library/Frameworks/SenTestingKit

Page 13: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

13 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

FoneMonkey Drops Down in Front of

Your Application Window

Page 14: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

14 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Recording

• Start recording by

tapping the Record

button

• Click the More button to

view recorded

commands

• Commands

can be

edited

Editing

Controls

Page 15: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

15 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Anatomy of a Command

• Command (Required)

• Class of component (optional)

• “MonkeyID” of component

(optional)

• Command-specific timeout

• Command-specific arguments

(Optional)

• Arguments have intelligent

defaults -- for example the

center coordinates of a

component

Page 16: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

16 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Component Identification

• Any combination of Component Class and/or

“MonkeyID”

• MonkeyID –

– accessibilityLabel property if it exists

– Intelligent value used if no accessibilityLabel – for example, the

label of a button

– If no value available, FoneMonkey assigns a unique ordinal (eg,

#1) for the instance of the Component Class

• Can become invalid if layout changes between recording and playback

– Can be set programmatically

Page 17: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

17 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Setting the Accessibility Label

• Set accessibilityLabel in code inputField.accessibilityLabel = @”First Name”;

• Or in Interface Builder “Identity Inspector”

Page 18: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

18 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Programmatically Setting MonkeyID

• In the class defintion @implementation MyComponent (FM_Ready)

- (NSString*) monkeyID {

return self.someIdentifyingStringProperty;

}

• Or in a category @implementation MyComponent (FM_Ready)

- (NSString*) monkeyID {

return self.someIdentifyingStringProperty;

}

Page 19: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

19 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Create a Verification Step

• Verify component

existence or String

property value

• Inserting new command

creates Verify

Page 20: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

20 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

The Verification Command

• Verifies existence of a

component

• Can also verify any

String property

expression

for an expected value

Page 21: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

21 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Verification failure reported

during playback

• Failures reported in

FoneMonkey console

• Full error in Xcode

console output

Page 22: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

22 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

WaitFor Command waits for

true, or timeout

• WaitFor works like Verify

• Can wait for property

value expression

• Waits until condition to

be true or until timeout

• Timeout specified in

milliseconds

• Often used to wait for

return of server results

Page 23: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

23 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Saving Scripts

• Save scripts with the

Save button

• Open with Open button

• Location of saved files

written to Xcode console

Page 24: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

24 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Scripts saved in three formats

• ScriptName.fm – Native Mac property list file.

• ScriptName.m – Ready-to-Run Objective-C OCUnit

Test

• ScriptName.js – Ready-to-Run JavaScript QUnit Test

• Saved in applications Documents directory

• Location of Documents directory written to Xcode

console

Page 25: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

25 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Extend recorded scripts with custom logic

• Scripts are readable, editable, and can also be

created from scratch without recording

• Scripts are saved in three formats

– “Native” fm file – XML editable with Xcode plist editor

– Objective-C – Ready to run with OCUnit

– JavaScript – Ready to run using FM_ENABLE_QUNIT env var

• Scripts can be extended with Objective-C code or

JavaScript

• Scripts can be run “headless” from the command line

Page 26: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

26 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Three Great Ways to Run

• Interactively from FoneMonkey Console

– Scripts stored in you application’s Documents directory

• Generated Objective-C OCUnit Tests

– Automatically launch OCUnit suites upon app startup (you can watch

the tests run)

– Run previously stored FoneMonkey scripts,

– Scripts can be extended with Objective-C and FoneMonkey API

– Can be run “Headless” in continuous integration environments

• Generated JavaScript QUnit Tests

Page 27: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

27 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Objective-C Code Generation

#import <SenTestingKit/SenTestingKit.h>

#import <UIKit/UIKit.h>

#import "FoneMonkeyAPI.h"@interface

Test1 : SenTestCase {

}

- (void) testSomething {

NSMutableArray* array = [NSMutableArray array];

[array addObject:[FMCommandEvent command:@"Touch"

className:@"UITableViewCell" monkeyID:@"TextView" args:

[NSArray arrayWithObjects:@"94", @"29", nil]]];

NSString* lastResult = [FoneMonkeyAPI playCommands:array];

STAssertNil(lastResult, lastResult);

}

“OCUnit” Test Case

Page 28: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

28 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Running Generated Objective-C

• Drag generated Objective-C into Xcode Project

• Add to testing target only

• Tests will run whenever you start your app

• Disable running of tests by removing

libFoneMonkeyOCUnit.a

Page 29: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

29 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Generated Objective-C

• Creates an array

• Populates array with FMCommandEvents

• Runs the commands

• Returns nil if successful or error message otherwise

Page 30: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

30 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Adding logic to generated code

- (void) testSomething {

NSMutableArray* array = [NSMutableArray array];

for (int i=0; i<10; i++) {

[array addObject:[FMCommandEvent command:@"Touch"

className:@"UITableViewCell”

monkeyID:@"TextView"

args: [NSArray arrayWithObjects:@"94”,

@"29", nil]]];

}

NSString* lastResult = [FoneMonkeyAPI playCommands:array];

STAssertNil(lastResult, lastResult);

}

Page 31: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

31 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

JavaScript Code Generation

$(document).ready(function(){

module("sliderTest Module");

asyncTest("sliderTest Test", function() {

// Build the command list

FM.commandList.add("Touch", "UITableViewCell", "Controls", "124", "35");

FM.commandList.addRetry("TouchLeft", "UINavigationBar", "Controls", "500",

"100", null);

// Execute the command list

FM.commandList.play(continuationFunction);

})

function continuationFunction(){

// Additional logic after commands are done playing

}

});

Page 32: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

32 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Running Generated JavaScript (QUnit)

Page 33: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

33 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

Running “Headless” in automated builds

• Copy test target and add “Run Script” phase

• Copy & paste script from FoneMonkey documentation

Page 34: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

34 Property of Gorilla Logic. Confidential and privileged.

Any unauthorized review, use, disclosure or distribution is prohibited

How can I get my very own Monkey?

• FoneMonkey is free and open source

• Licensed under the GPL (“Copyleft”)

• Available for download at

www.gorillalogic.com/fonemonkey

– Free registration required

• Gorilla Logic provides training, quickstarts, and

customization services

– We can also write software for you, with you, or show you how to

do it better yourself

Page 35: FoneMonkey for iOSfiles.meetup.com/2625872/FoneMonkeyOverviewKB.pdf · 2 Property of Gorilla Logic. Confidential and privileged. Any unauthorized review, use, disclosure or distribution

Property of Gorilla Logic. Confidential.

Kyle Balogh

[email protected]