Skip to content

Commit

Permalink
Merge pull request #99 from DeluxeAlonso/automation-tests
Browse files Browse the repository at this point in the history
Automation tests - Swipe to delete
  • Loading branch information
DeluxeAlonso committed Feb 4, 2024
2 parents 6558323 + f6fc481 commit 0973acb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CalculatorReplicaSwiftUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
E2B2EDB32B0BD5DE00F0F2AA /* CalculatorOperationHandlerMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2B2EDB22B0BD5DE00F0F2AA /* CalculatorOperationHandlerMock.swift */; };
E2B2EDB52B0BFE5900F0F2AA /* CalculatorResultFormatterMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2B2EDB42B0BFE5900F0F2AA /* CalculatorResultFormatterMock.swift */; };
E2BB83C42B6F5B9900D636F3 /* CalculatorPageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2BB83C32B6F5B9800D636F3 /* CalculatorPageModel.swift */; };
E2BCF1CD2B6FF01800BA50AD /* AutomationTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2BCF1CC2B6FF01800BA50AD /* AutomationTestCase.swift */; };
E2C600322448229C0099A038 /* PendingBinaryOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C600312448229C0099A038 /* PendingBinaryOperation.swift */; };
E2C60034244822EE0099A038 /* CalculatorResultFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C60033244822EE0099A038 /* CalculatorResultFormatter.swift */; };
E2C60038244824AB0099A038 /* CalculatorResultFormatterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C60037244824AB0099A038 /* CalculatorResultFormatterProtocol.swift */; };
Expand Down Expand Up @@ -158,6 +159,7 @@
E2B2EDB22B0BD5DE00F0F2AA /* CalculatorOperationHandlerMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalculatorOperationHandlerMock.swift; sourceTree = "<group>"; };
E2B2EDB42B0BFE5900F0F2AA /* CalculatorResultFormatterMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalculatorResultFormatterMock.swift; sourceTree = "<group>"; };
E2BB83C32B6F5B9800D636F3 /* CalculatorPageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalculatorPageModel.swift; sourceTree = "<group>"; };
E2BCF1CC2B6FF01800BA50AD /* AutomationTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutomationTestCase.swift; sourceTree = "<group>"; };
E2C600312448229C0099A038 /* PendingBinaryOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PendingBinaryOperation.swift; sourceTree = "<group>"; };
E2C60033244822EE0099A038 /* CalculatorResultFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalculatorResultFormatter.swift; sourceTree = "<group>"; };
E2C60037244824AB0099A038 /* CalculatorResultFormatterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalculatorResultFormatterProtocol.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -343,6 +345,7 @@
E228C6C02B5A517B00A78834 /* CalculatorReplicaSwiftUIAutomationTests */ = {
isa = PBXGroup;
children = (
E2BCF1CB2B6FEFE000BA50AD /* Base */,
E228C6C12B5A517B00A78834 /* CalculatorReplicaSwiftUIAutomationTests.swift */,
E2BB83C32B6F5B9800D636F3 /* CalculatorPageModel.swift */,
);
Expand Down Expand Up @@ -435,6 +438,14 @@
path = Base;
sourceTree = "<group>";
};
E2BCF1CB2B6FEFE000BA50AD /* Base */ = {
isa = PBXGroup;
children = (
E2BCF1CC2B6FF01800BA50AD /* AutomationTestCase.swift */,
);
path = Base;
sourceTree = "<group>";
};
E2CAA05C24553AEA00C4DBC9 /* Factories */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -730,6 +741,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E2BCF1CD2B6FF01800BA50AD /* AutomationTestCase.swift in Sources */,
E228C6C22B5A517B00A78834 /* CalculatorReplicaSwiftUIAutomationTests.swift in Sources */,
E2BB83C42B6F5B9900D636F3 /* CalculatorPageModel.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// AutomationTestCase.swift
// CalculatorReplicaSwiftUIAutomationTests
//
// Created by Alonso on 4/02/24.
// Copyright © 2024 Alonso. All rights reserved.
//

import XCTest

class AutomationTestCase: XCTestCase {

var app: XCUIApplication!

override func setUpWithError() throws {
try super.setUpWithError()
app = XCUIApplication()
}

override func tearDownWithError() throws {
app = nil
try super.tearDownWithError()
}

func launch() {
app.launch()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ final class CalculatorPageModel {
self.app = app
}

// MARK: - Buttons

var one: XCUIElement { app.buttons["one"] }
var two: XCUIElement { app.buttons["two"] }
var three: XCUIElement { app.buttons["three"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
@testable import Calculator
import XCTest

final class CalculatorReplicaSwiftUIAutomationTests: XCTestCase {
final class CalculatorReplicaSwiftUIAutomationTests: AutomationTestCase {

private var pageModel: CalculatorPageModel!

override func setUpWithError() throws {
try super.setUpWithError()
let app = XCUIApplication()
app.launch()
pageModel = CalculatorPageModel(app: app)

launch()
}

override func tearDownWithError() throws {
Expand Down Expand Up @@ -180,4 +180,18 @@ final class CalculatorReplicaSwiftUIAutomationTests: XCTestCase {
XCTAssertEqual(pageModel.resultDisplay.label, "11")
}

func testSwipeToDelete() {
pageModel.eight.tap()
pageModel.eight.tap()
pageModel.eight.tap()

XCTAssertEqual(pageModel.resultDisplay.label, "888")
pageModel.resultDisplay.swipeLeft()
XCTAssertEqual(pageModel.resultDisplay.label, "88")
pageModel.resultDisplay.swipeRight()
XCTAssertEqual(pageModel.resultDisplay.label, "8")
pageModel.resultDisplay.swipeLeft()
XCTAssertEqual(pageModel.resultDisplay.label, "0")
}

}

0 comments on commit 0973acb

Please sign in to comment.