-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
288 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Run UI Test Cases | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- "feature/*" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ui-tests: | ||
name: Run iOS UI Tests | ||
runs-on: macOS-14 | ||
env: | ||
DEVELOPER_DIR: "/Applications/Xcode_15.3.app/Contents/Developer" | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Reset Simulators | ||
run: xcrun simctl erase all | ||
- name: Run UI Tests | ||
run: | | ||
set -o pipefail | ||
xcodebuild -project "mobile-courier-app.xcodeproj" -scheme "mobile-courier-appUITests" -destination "platform=iOS Simulator,OS=17.4,name=iPhone 15 Pro" -derivedDataPath build/ -resultBundlePath ui-test-results.xcresult test | xcpretty | ||
- name: Compress UI Test Results | ||
if: failure() | ||
run: tar -czf ui-test-results.xcresult.tar.gz ui-test-results.xcresult | ||
- name: Upload UI Test Results | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ui-test-results | ||
path: ui-test-results.xcresult.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
mobile-courier-app.xcodeproj/xcshareddata/xcschemes/mobile-courier-appUITests.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1540" | ||
version = "2.2"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES" | ||
buildArchitectures = "Automatic"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "NO" | ||
buildForArchiving = "NO" | ||
buildForAnalyzing = "NO"> | ||
<AutocreatedTestPlanReference> | ||
</AutocreatedTestPlanReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO" | ||
parallelizable = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "1B58EF8D2BE6BBEA0066F447" | ||
BuildableName = "mobile-courier-appUITests.xctest" | ||
BlueprintName = "mobile-courier-appUITests" | ||
ReferencedContainer = "container:mobile-courier-app.xcodeproj"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "1B58EF8D2BE6BBEA0066F447" | ||
BuildableName = "mobile-courier-appUITests.xctest" | ||
BlueprintName = "mobile-courier-appUITests" | ||
ReferencedContainer = "container:mobile-courier-app.xcodeproj"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
mobile-courier-appUITests/Extensions/XCUIElement+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// XCUIElement+Extensions.swift | ||
// mobile-courier-appUITests | ||
// | ||
// Created by Vladimir Espinola on 2024-06-27. | ||
// | ||
|
||
import XCTest | ||
|
||
enum Timeout { | ||
static var `default`: TimeInterval { 10 } | ||
static var max: TimeInterval { 15 } | ||
} | ||
|
||
extension XCUIElement { | ||
func tapOnElement(timeout: TimeInterval = Timeout.default) { | ||
guard elementExists(timeout: timeout) else { | ||
XCTFail("\(description) does not exists") | ||
return | ||
} | ||
tap() | ||
} | ||
|
||
func elementExists(timeout: TimeInterval = Timeout.default) -> Bool { | ||
waitForExistence(timeout: timeout) | ||
} | ||
|
||
func fillTextField(_ text: String) { | ||
guard elementExists() else { | ||
XCTFail("\(description) does not exists") | ||
return | ||
} | ||
|
||
typeText(text) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// HomeScreen.swift | ||
// mobile-courier-appUITests | ||
// | ||
// Created by Vladimir Espinola on 2024-06-27. | ||
// | ||
|
||
import XCTest | ||
|
||
struct HomeScreen: Screen { | ||
private init() {} | ||
|
||
@discardableResult | ||
static func verifyUsername() -> Self.Type { | ||
XCTAssertTrue(headerText.elementExists()) | ||
return self | ||
} | ||
|
||
@discardableResult | ||
static func verifyShipment(by id: Int) -> Self.Type { | ||
XCTAssertTrue(app.staticTexts["GroupedPackageRowView-\(id)"].elementExists()) | ||
return self | ||
} | ||
} | ||
|
||
private extension HomeScreen { | ||
static var headerText: XCUIElement { | ||
app.staticTexts["HeaderView-UsernameLabel"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// LoginScreen.swift | ||
// mobile-courier-appUITests | ||
// | ||
// Created by Vladimir Espinola on 2024-06-27. | ||
// | ||
|
||
import XCTest | ||
|
||
struct LoginScreen: Screen { | ||
private init() {} | ||
|
||
@discardableResult | ||
static func performLogin(email: String, password: String) -> Self.Type { | ||
sleep(2) | ||
emailTextField.fillTextField(email) | ||
passwordTextField.fillTextField(password) | ||
loginButton.tapOnElement() | ||
return self | ||
} | ||
} | ||
|
||
private extension LoginScreen { | ||
static var loginButton: XCUIElement { app.buttons["Login-Button"] | ||
} | ||
|
||
static var emailTextField: XCUIElement { | ||
app.descendants(matching: .any)["Login-Email"] | ||
} | ||
|
||
static var passwordTextField: XCUIElement { | ||
app.descendants(matching: .any)["Login-Password"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// Screen.swift | ||
// mobile-courier-appUITests | ||
// | ||
// Created by Vladimir Espinola on 2024-06-27. | ||
// | ||
|
||
import XCTest | ||
|
||
protocol Screen { } | ||
|
||
extension Screen { | ||
static var app: XCUIApplication { | ||
.init() | ||
} | ||
} |