From 7b32c24e6a1521320ec2c55fd2ab45e501814d79 Mon Sep 17 00:00:00 2001 From: CypherPoet Date: Fri, 15 Mar 2019 05:02:47 -0400 Subject: [PATCH] Add UI testing --- .../iOS_Unit_TestingUITests.swift | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/39-ios-unit-testing/iOS Unit Testing/iOS Unit TestingUITests/iOS_Unit_TestingUITests.swift b/39-ios-unit-testing/iOS Unit Testing/iOS Unit TestingUITests/iOS_Unit_TestingUITests.swift index db3f57c..417d58f 100644 --- a/39-ios-unit-testing/iOS Unit Testing/iOS Unit TestingUITests/iOS_Unit_TestingUITests.swift +++ b/39-ios-unit-testing/iOS Unit Testing/iOS Unit TestingUITests/iOS_Unit_TestingUITests.swift @@ -26,9 +26,28 @@ class iOS_Unit_TestingUITests: XCTestCase { // Put teardown code here. This method is called after the invocation of each test method in the class. } - func testExample() { - // Use recording to get started writing UI tests. - // Use XCTAssert and related functions to verify your tests produce the correct results. + func testInitialCellCount() { + let tables = XCUIApplication().tables + let expected = 7 + let actual = tables.cells.count + + XCTAssertEqual(actual, expected, "cell count did not match \(expected)") + } + + + func testFilteringDialog() { + let app = XCUIApplication() + app.navigationBars["📜 Shakespeare Word Count"].buttons["🎯 Filter"].tap() + + let alertDialog = app.alerts["Show words that include:"] + + alertDialog.textFields.element.typeText("truth") + alertDialog.buttons["OK"].tap() + + let expected = 4 + let actual = app.tables.cells.count + + XCTAssertEqual(actual, expected, "table view did not contain \(expected) cells") } }