Testing iOS Apps Graham Lee / @secboffin Monday, 25 March 13 - - PowerPoint PPT Presentation

testing ios apps
SMART_READER_LITE
LIVE PREVIEW

Testing iOS Apps Graham Lee / @secboffin Monday, 25 March 13 - - PowerPoint PPT Presentation

Testing iOS Apps Graham Lee / @secboffin Monday, 25 March 13 Penetration Unit Integration Whole-app A lot to cover Monday, 25 March 13 Agenda Monday, 25 March 13 Agenda High-level overview of testing options Monday, 25 March 13


slide-1
SLIDE 1

Testing iOS Apps

Graham Lee / @secboffin

Monday, 25 March 13

slide-2
SLIDE 2

A lot to cover

Unit Integration Whole-app Penetration

Monday, 25 March 13

slide-3
SLIDE 3

Agenda

Monday, 25 March 13

slide-4
SLIDE 4

Agenda

  • High-level overview of testing options

Monday, 25 March 13

slide-5
SLIDE 5

Agenda

  • High-level overview of testing options
  • Native iOS apps, with some browser

component

Monday, 25 March 13

slide-6
SLIDE 6

Agenda

  • High-level overview of testing options
  • Native iOS apps, with some browser

component

  • Unit tests

Monday, 25 March 13

slide-7
SLIDE 7

Agenda

  • High-level overview of testing options
  • Native iOS apps, with some browser

component

  • Unit tests
  • Integration tests

Monday, 25 March 13

slide-8
SLIDE 8

Agenda

  • High-level overview of testing options
  • Native iOS apps, with some browser

component

  • Unit tests
  • Integration tests
  • Penetration tests

Monday, 25 March 13

slide-9
SLIDE 9

Unit Tests

  • OCUnit built into

Xcode

  • Reasonable GUI

Integration as of v4

  • Baroque and outdated

syntax

Monday, 25 March 13

slide-10
SLIDE 10

Monday, 25 March 13

slide-11
SLIDE 11

Monday, 25 March 13

slide-12
SLIDE 12

@implementation StackOverflowCommunicatorTests

  • (void)setUp {

communicator = [[InspectableStackOverflowCommunicator alloc] init]; }

  • (void)tearDown {

[communicator cancelAndDiscardURLConnection]; }

  • (void)testSearchingForQuestionsOnTopicCallsTopicAPI {

[communicator searchForQuestionsWithTag: @"ios"]; STAssertEqualObjects([[communicator URLToFetch] absoluteString], @"http:// api.stackoverflow.com/1.1/search?tagged=ios&pagesize=20", @"Use the search API to find questions with a particular tag"); } @end

Monday, 25 March 13

slide-13
SLIDE 13

https://github.com/philSquared/Catch

“CATCH stands for C++ Automated Test Cases in Headers and is a multi-paradigm automated test framework for C, C++ and Objective-C. It is implemented entirely in a set of headers, but is packaged up as a single header for extra convenience.”

Monday, 25 March 13

slide-14
SLIDE 14

TEST_CASE("parser/API", "Design the public interface for the parser") { FZASourceParser *parser = [FZASourceParser new]; SECTION("acceptableIO", "Accept unparsed, generate parsed targets") { TestBuildTarget *target = [TestBuildTarget new]; id <FZABuildTarget> output = nil; target.parsed = YES; CHECK_THROWS(output = [parser parse: target]); CHECK(output == nil); target.parsed = NO; CHECK_NOTHROW(output = [parser parse: target]); CHECK([output conformsToProtocol: @protocol(FZABuildTarget)]); CHECK([[output name] isEqualToString: [target name]]); CHECK([output isParsed] == YES); [target release]; } [parser release]; } TEST_CASE("parser/run", "Run through the test project and see what we find") { FZASourceParser *parser = [FZASourceParser new]; FZAXcodeProject *project = [[FZAXcodeProject alloc] initWithProjectFolder: @"TestProject.xcodeproj"]; id <FZABuildTarget>parsedTarget = [parser parse: [project targetAtIndex: 0]]; REQUIRE(parsedTarget != nil); CHECK([parsedTarget countOfFunctions] == 1); [project release]; [parser release]; }

Monday, 25 March 13

slide-15
SLIDE 15

It’s not a “unit test” framework…

  • …it’s a framework for running tests
  • …and for reporting test results
  • Integration tests, whole-app tests

Monday, 25 March 13

slide-16
SLIDE 16

Calabash

  • https://github.com/calabash/calabash-ios
  • http://calaba.sh
  • BDD-style spec format for tests
  • Automatic runner/reporter

Monday, 25 March 13

slide-17
SLIDE 17

$ calabash- ios console

> query("label") … [0] { "rect" => { "center_y" => 261.5, "width" => 300, "center_x" => 160, "height" => 43, "x" => 10, "y" => 240 }, "frame" => { "width" => 300, "height" => 43, "x" => 10, "y" => 0 }, "description" => "<UILabel: 0x72f0920; frame = (10 0; 300 43); text = 'iPhone'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x72f09b0>>", "UIType" => "UIView", "class" => "UILabel" }, …

Monday, 25 March 13

slide-18
SLIDE 18

$ calabash- ios console

> touch(query("label marked:'iPhone'"))

Monday, 25 March 13

slide-19
SLIDE 19

Given I am on the Welcome Screen Then I choose the section iPhone And take picture

Then "I choose the section $section" do |section| touch("view label text:'#{section}'") end

Monday, 25 March 13

slide-20
SLIDE 20

Monday, 25 March 13

slide-21
SLIDE 21

Monday, 25 March 13

slide-22
SLIDE 22

var target = UIATarget.localTarget(); var app = target.frontMostApp(); var window = app.mainWindow(); target.logElementTree();

Monday, 25 March 13

slide-23
SLIDE 23

Monday, 25 March 13

slide-24
SLIDE 24

Monday, 25 March 13

slide-25
SLIDE 25

var target = UIATarget.localTarget(); var app = target.frontMostApp(); var window = app.mainWindow(); var tableView = window.tableViews()[0]; var iPhoneCell = tableView.cells() ["iPhone"]; iPhoneCell.tap();

WWDC 2010 Session 306: Automating UI Testing with Instruments

Monday, 25 March 13

slide-26
SLIDE 26

Testing app-bundled JS

Monday, 25 March 13

slide-27
SLIDE 27

Monday, 25 March 13

slide-28
SLIDE 28

Monday, 25 March 13

slide-29
SLIDE 29

Monday, 25 March 13

slide-30
SLIDE 30

Monday, 25 March 13

slide-31
SLIDE 31

Monday, 25 March 13

slide-32
SLIDE 32

Monday, 25 March 13

slide-33
SLIDE 33

–[UIWebView stringByEvaluatingJavaScriptFromString:]

Monday, 25 March 13

slide-34
SLIDE 34

Monday, 25 March 13

slide-35
SLIDE 35

https://www.owasp.org/index.php/ IOS_Developer_Cheat_Sheet

Monday, 25 March 13

slide-36
SLIDE 36

Testing iOS Apps

Graham Lee / @secboffin

Monday, 25 March 13