fonemonkey for iosfiles.meetup.com/2625872/fonemonkeyoverviewkb.pdf · 2 property of gorilla logic....
TRANSCRIPT
![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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/1.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/2.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/3.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/4.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/5.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/6.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/7.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/8.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/9.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/10.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/11.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/12.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/13.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/14.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/15.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/16.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/17.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/18.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/19.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/20.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/21.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/22.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/23.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/24.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/25.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/26.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/27.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/28.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/29.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/30.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/31.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/32.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/33.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022070113/605adedfca271c16ff7fea97/html5/thumbnails/34.jpg)
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