cocoaheads • aug 2018 ui tdd tdd · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing....

175
UI TDD COCOAHEADS • AUG 2018 TDD

Upload: others

Post on 20-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TDDCOCOAHEADS • AUG 2018

TDD

Page 2: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TDDCOCOAHEADS • AUG 2018

TDD

Page 3: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTING

Page 4: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTING

Page 5: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGRepeatability

Page 6: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGRepeatability

🙏

INFORMAL MANUAL TESTING

Page 7: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGRepeatability

🙏

INFORMAL MANUAL TESTING

📋

FORMAL MANUAL TESTING

Page 8: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGRepeatability

🙏

INFORMAL MANUAL TESTING

📋

FORMAL MANUAL TESTING

🤖

AUTOMATEDTESTING

Page 9: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

UNITINPUT OUTPUT

Page 10: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

UNIT

Page 11: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

Page 12: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

INTEGRATION

Page 13: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

Page 14: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

END-TO-END

Page 15: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

END-TO-ENDINTEGRATIONUNIT

Page 16: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

END-TO-ENDINTEGRATIONUNIT

Page 17: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATEDTime/Complexity

END-TO-ENDINTEGRATIONUNIT

Page 18: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATEDTime/Complexity

Realism

END-TO-ENDINTEGRATIONUNIT

Page 19: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

END-TO-ENDINTEGRATIONUNIT

Time/ComplexityRealism

📲 UI TESTS

Page 20: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

Page 21: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

Page 22: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

Page 23: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

Page 24: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

Page 25: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

Page 26: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

%

VERIFY BEHAVIOR

Page 27: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

BUILT ON ACCESSIBILITY

%

VERIFY BEHAVIOR

Page 28: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

%

VERIFY BEHAVIOR

BUILT ON ACCESSIBILITY

RECORD TO LEARN

Page 29: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Page 30: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Page 31: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Page 32: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Title

Page 33: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Title

Page 34: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Title

Table

Page 35: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Title

Cell

Table

Page 36: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

ButtonTitle

Cell

Table

Page 37: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Page 38: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

Button

Title

Cell

Page 39: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

TitleButton

Title

Cell

Page 40: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

Title

Label

Button

Title

Cell

Page 41: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

Button

Title

Label

Button

Title

Cell

Page 42: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

Button

Title

Label

Button

Title

Cell

Page 43: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

Button

Title

Label

TapButton

Title

Cell

Page 44: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

Button

Title

Label

TapButton

Title

CellSwipe

Page 45: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Table

Button

Title

Label

Tap

Tap

Button

Title

CellSwipe

Page 46: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Page 47: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Page 48: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

Page 49: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

Page 50: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

Text

Page 51: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

CountText

Page 52: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

CountText

Text

Page 53: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

CountText

Text

Text

Page 54: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

CountText Text

Text

Text

Page 55: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

CountText Text

Title

Text

Page 56: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

CountText Text

Title

Text

Page 57: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BETTER UI TESTING

Button

Button

Button

Title

Cell

Table

Button

Title

Label

Tap

Tap

Tap

Swipe

Tap

Tap

CountText Text

Title

Text

Page 58: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BENEFITS

Page 59: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BENEFITS

&

EASIER TO READ

Page 60: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BENEFITS

XCUIApplication().tables.children(matching: .cell).element(boundBy: 0).staticTexts["2018-07-03 20:45:14 +0000"].tap()

Before

&

EASIER TO READ

Page 61: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BENEFITS

.tapOnCell(at: 0)

Before

After

XCUIApplication().tables.children(matching: .cell).element(boundBy: 0).staticTexts["2018-07-03 20:45:14 +0000"].tap()

&

EASIER TO READ

Page 62: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BENEFITS

&

EASIER TO READ

'

EASIER TO MAINTAIN

Page 63: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

BENEFITS

&

EASIER TO READ

'

EASIER TO MAINTAIN

(

WRITE TESTS FIRST!

Page 64: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

&

EASIER TO READ

BENEFITS

'

EASIER TO MAINTAIN

TDD

(

WRITE TESTS FIRST!

Page 65: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDDTEST-DRIVEN DEVELOPMENT

Page 66: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

)

Page 67: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

)

Page 68: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 69: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 70: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 71: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 72: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 73: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 74: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 75: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

()

Page 76: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

{

}

{

}

()

Page 77: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

{

}

{

}

()

Page 78: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

Page 79: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

Page 80: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

// MARK: - Actions // MARK: - Verifications

}

Page 81: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

// MARK: - Actions // MARK: - Verifications

}

import XCTest

protocol TestPage { var testCase: XCTestCase { get }}

extension TestPage { var app: XCUIApplication { return XCUIApplication() } }

Page 82: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

// MARK: - Actions // MARK: - Verifications

}

Page 83: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

// MARK: - Actions // MARK: - Verifications

}

Page 84: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate var detailText: XCUIElement { return app.staticTexts[“DetailViewController.label"] } fileprivate var backButton: XCUIElement { return app.navigationBars.buttons["Master"] } ...

Page 85: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate var detailText: XCUIElement { return app.staticTexts[“DetailViewController.label"] } fileprivate var backButton: XCUIElement { return app.navigationBars.buttons["Master"] } ...

Button

Label

Page 86: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate var detailText: XCUIElement { return app.staticTexts[“DetailViewController.label"] } fileprivate var backButton: XCUIElement { return app.navigationBars.buttons["Master"] } ...

Page 87: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

}

fileprivate var detailText: XCUIElement { return app.staticTexts[“DetailViewController.label"] } fileprivate var backButton: XCUIElement { return app.navigationBars.buttons["Master"] } ...

Page 88: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

}

fileprivate var detailText: XCUIElement { return app.staticTexts[“DetailViewController.label"] } fileprivate var backButton: XCUIElement { return app.navigationBars.buttons["Master"] } ...

Page 89: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

}

fileprivate var detailText: XCUIElement { return app.staticTexts[“DetailViewController.label"] } fileprivate var backButton: XCUIElement { return app.navigationBars.buttons["Master"] } ...

Page 90: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

CODE

Page 91: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

CODE

Tap

Page 92: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

CODE

Page 93: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

CODE

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 94: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

CODE

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 95: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

CODE

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 96: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

func expect(exists element: XCUIElement, file: String = #file, line: UInt = #line) { if !element.exists { recordFailure(withDescription: "Expected \(element) to exist.", inFile: file, atLine: Int(line), expected: true) } }

...

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 97: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

func expect(exists element: XCUIElement, file: String = #file, line: UInt = #line) { if !element.exists { recordFailure(withDescription: "Expected \(element) to exist.", inFile: file, atLine: Int(line), expected: true) } }

...

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 98: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

func expect(exists element: XCUIElement, file: String = #file, line: UInt = #line) { if !element.exists { recordFailure(withDescription: "Expected \(element) to exist.", inFile: file, atLine: Int(line), expected: true) } }

...

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 99: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

func expect(exists element: XCUIElement, file: String = #file, line: UInt = #line) { if !element.exists { recordFailure(withDescription: "Expected \(element) to exist.", inFile: file, atLine: Int(line), expected: true) } }

...

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 100: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

func expect(exists element: XCUIElement, file: String = #file, line: UInt = #line) { if !element.exists { recordFailure(withDescription: "Expected \(element) to exist.", inFile: file, atLine: Int(line), expected: true) } }

...

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 101: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

CODE

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

Page 102: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

@discardableResult func tapOnBackButton(file: StaticString = #file, line: UInt = #line) -> MasterPage { XCTAssertTrue(backButton.exists, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

... }

Page 103: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

@discardableResult func tapOnBackButton(file: StaticString = #file, line: UInt = #line) -> MasterPage { XCTAssertTrue(backButton.exists, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

... }

Page 104: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

CODE

Page 105: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

CODE

Page 106: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct DetailPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func tapOnBackButton(file: String = #file, line: UInt = #line) -> MasterPage { testCase.expect(exists: backButton, file: file, line: line) backButton.tap() return MasterPage(testCase: testCase) }

CODE

Page 107: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Page 108: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Page 109: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Page 110: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file:

CODE

// MARK: - Elements

fileprivate var detailText: XCUIElement { return app.staticTexts[“DetailViewController.label"] }

Page 111: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Page 112: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Page 113: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Text

Page 114: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Page 115: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

...

// MARK: - Verifications @discardableResult func verifyDetailPageIsShowing(file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) return self } @discardableResult func verifyLabelText(is text: String, file: String = #file, line: UInt = #line) -> DetailPage { testCase.expect(exists: detailText, file: file, line: line) testCase.expect(detailText.label, equals: text, file: file, line: line) return self } ... }

Page 116: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

Page 117: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

Page 118: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

class BasicEntryUITests: XCTestCase {

}

Page 119: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

class BasicEntryUITests: XCTestCase { override func setUp() { super.setUp() continueAfterFailure = false let application = XCUIApplication() application.launchArguments.append("--uitesting") application.launch() }

}

Page 120: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

class BasicEntryUITests: XCTestCase { override func setUp() { super.setUp() continueAfterFailure = false let application = XCUIApplication() application.launchArguments.append("--uitesting") application.launch() }

}

Page 121: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

class BasicEntryUITests: XCTestCase { override func setUp() { super.setUp() continueAfterFailure = false let application = XCUIApplication() application.launchArguments.append("--uitesting") application.launch() }

}

Page 122: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

super.setUp() continueAfterFailure = false let application = XCUIApplication() application.launchArguments.append("--uitesting") application.launch() }

}

class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { if CommandLine.arguments.contains("--uitesting") { // Set up state for UI testing } ... } }

Page 123: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

super.setUp() continueAfterFailure = false let application = XCUIApplication() application.launchArguments.append("--uitesting") application.launch() }

}

class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { if CommandLine.arguments.contains("--uitesting") { // Set up state for UI testing } ... } }

Page 124: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

import XCTest

class BasicEntryUITests: XCTestCase { override func setUp() { super.setUp() continueAfterFailure = false let application = XCUIApplication() application.launchArguments.append("--uitesting") application.launch() }

}

Page 125: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() {

}

...

Page 126: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { MasterPage(testCase: self)

}

...

Page 127: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { MasterPage(testCase: self) .verifyMasterPageIsShowing()

}

...

Page 128: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0)

}

...

Page 129: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton()

}

...

Page 130: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1)

}

...

Page 131: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: )

}

...

Page 132: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel)

}

...

Page 133: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel) .tapOnCell(at: 0)

}

Page 134: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing()

}

Page 135: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: nowLabel)

}

...

Page 136: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: nowLabel) .tapOnBackButton()

}

...

Page 137: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: nowLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Page 138: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: nowLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Page 139: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let nowLabel = String(describing: Date()) MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: nowLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: nowLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Expected ‘Optional(…

Page 140: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let zeroLabel = "0" MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: zeroLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: zeroLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Page 141: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingEntry() { let zeroLabel = "0" MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: zeroLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: zeroLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Page 142: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingAndDeletingEntry() { let zeroLabel = "0" MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: zeroLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: zeroLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Page 143: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingAndDeletingEntry() { let zeroLabel = "0" MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: zeroLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: zeroLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Page 144: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate func cell(at index: Int) -> XCUIElement { return table.cells.element(boundBy: index)} fileprivate func deleteButton(for cell: XCUIElement) -> XCUIElement { return cell.buttons["Delete"]} ...

Page 145: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate func cell(at index: Int) -> XCUIElement { return table.cells.element(boundBy: index)} fileprivate func deleteButton(for cell: XCUIElement) -> XCUIElement { return cell.buttons["Delete"]} ...

Button

Page 146: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate func cell(at index: Int) -> XCUIElement { return table.cells.element(boundBy: index)} fileprivate func deleteButton(for cell: XCUIElement) -> XCUIElement { return cell.buttons["Delete"]} ...

Page 147: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate func cell(at index: Int) -> XCUIElement { return table.cells.element(boundBy: index)} fileprivate func deleteButton(for cell: XCUIElement) -> XCUIElement { return cell.buttons["Delete"]} ...

Page 148: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate func cell(at index: Int) -> XCUIElement { return table.cells.element(boundBy: index)} fileprivate func deleteButton(for cell: XCUIElement) -> XCUIElement { return cell.buttons["Delete"]} ...

Page 149: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { let testCase: XCTestCase

// MARK: - Elements

} CODE

fileprivate func cell(at index: Int) -> XCUIElement { return table.cells.element(boundBy: index)} fileprivate func deleteButton(for cell: XCUIElement) -> XCUIElement { return cell.buttons["Delete"]} ...

Page 150: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 151: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Tap

Page 152: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 153: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 154: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 155: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 156: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 157: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 158: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

import XCTest

struct MasterPage: TestPage { ...

// MARK: - Actions

... }

@discardableResult func deleteCell(at index: Int, file: String = #file, line: UInt = #line) -> MasterPage { let cell = self.cell(at: index) testCase.expect(exists: cell, file: file, line: line) cell.swipeLeft() let deleteButton = self.deleteButton(for: cell) testCase.expect(exists: deleteButton, file: file, line: line) deleteButton.tap() return self}

CODE

Page 159: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingAndDeletingEntry() { let zeroLabel = "0" MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: zeroLabel) .tapOnCell(at: 0) // Detail page .verifyDetailPageIsShowing() .verifyLabelText(is: zeroLabel) .tapOnBackButton() // Master page .verifyMasterPageIsShowing() }

...

Page 160: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingAndDeletingEntry() { let zeroLabel = "0" MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: zeroLabel) .tapOnCell(at: 0) ... // Master page .verifyMasterPageIsShowing()

}

...

Page 161: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

CODE

... func testAddingAndDeletingEntry() { let zeroLabel = "0" MasterPage(testCase: self) .verifyMasterPageIsShowing() .verifyTableCellCount(is: 0) .tapOnAddButton() .verifyTableCellCount(is: 1) .verifyCell(at: 0, hasLabel: zeroLabel) .tapOnCell(at: 0) ... // Master page .verifyMasterPageIsShowing() .verifyTableCellCount(is: 1) .deleteCell(at: 0) .verifyTableCellCount(is: 0) }

...

Page 162: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TIPS & TRICKS

Page 163: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TIPS & TRICKS

WWDC2018Testing Tips & Tricks🎞2017Engineering for Testability

🎞

Page 164: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TIPS & TRICKS

📼

LOCAL DATA

Page 165: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TIPS & TRICKS

📼

LOCAL DATA

🚫

AVOID DUPLICATION

Page 166: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TIPS & TRICKS

📼

LOCAL DATA

🚫

AVOID DUPLICATION

USE MULTIPLE SCHEMES

Page 167: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

GETTING STARTED

Page 168: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

GETTING STARTED

📰

NEXT BUG/FEATURE

Page 169: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

GETTING STARTED

🔑

IMPORTANT FREQUENT

📰

NEXT BUG/FEATURE

Page 170: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

GETTING STARTED

🔑

IMPORTANT FREQUENT

IMPORTANT INFREQUENT

📰

NEXT BUG/FEATURE

Page 171: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SUMMARY

Page 172: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

SOFTWARE TESTINGAUTOMATED

END-TO-ENDINTEGRATIONUNIT

Page 173: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TESTS

%

VERIFY BEHAVIOR

BUILT ON ACCESSIBILITY

RECORD TO LEARN

Page 174: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

TDD

{

}

{

}

()

Page 175: COCOAHEADS • AUG 2018 UI TDD TDD · 2019-05-24 · cocoaheads • aug 2018 tdd. software testing. software testing. software testing repeatability. software testing repeatability!

UI TDDCOCOAHEADS • AUG 2018

1 //BSN.DESIGN

TDD