-
-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Run UI Tests in SauceLab (#1464)
Instead of AppCenter, run the UI tests in SauceLab. I split up the tests and relaunch the app for every screen to make the tests more stable.
- Loading branch information
1 parent
73b8114
commit 3c106ee
Showing
3 changed files
with
78 additions
and
33 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
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 @@ | ||
apiVersion: v1alpha | ||
kind: xcuitest | ||
sauce: | ||
region: us-west-1 | ||
concurrency: 2 | ||
|
||
defaults: | ||
timeout: 5m | ||
|
||
retries: 2 | ||
|
||
xcuitest: | ||
app: ./DerivedData/Build/Products/Debug-iphoneos/iOS-Swift.app | ||
testApp: ./DerivedData/Build/Products/Debug-iphoneos/iOS-SwiftUITests-Runner.app | ||
|
||
suites: | ||
- name: "iOS-Swift" | ||
devices: | ||
- name: "iPhone.*" | ||
orientation: "portrait" | ||
platformVersion: "15.1" | ||
|
||
- name: "iPhone.*" | ||
orientation: "portrait" | ||
platformVersion: "14.8" | ||
|
||
# Tests don't work currently on iOS 13.7, because Start of XCUITest-Runner times out. | ||
|
||
artifacts: | ||
download: | ||
when: always | ||
match: | ||
- "*.junit.xml" | ||
directory: ./artifacts/ |
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 |
---|---|---|
@@ -1,24 +1,46 @@ | ||
import XCTest | ||
|
||
class LaunchUITests: XCTestCase { | ||
|
||
private let timeout: TimeInterval = 10 | ||
private let app: XCUIApplication = XCUIApplication() | ||
|
||
override func setUpWithError() throws { | ||
try super.setUpWithError() | ||
continueAfterFailure = false | ||
} | ||
|
||
func testLaunch() { | ||
let app = XCUIApplication() | ||
app.launch() | ||
|
||
func visitScreen(buttonText: String) { | ||
app.buttons[buttonText].tap() | ||
app.swipeDown(velocity: .fast) | ||
} | ||
app.launch() | ||
XCUIDevice.shared.orientation = .portrait | ||
|
||
visitScreen(buttonText: "Lorem Ipsum") | ||
visitScreen(buttonText: "Test Navigation Transaction") | ||
visitScreen(buttonText: "Show Nib") | ||
visitScreen(buttonText: "Show SwiftUI") | ||
waitForExistenseOfMainScreen() | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
try super.tearDownWithError() | ||
app.terminate() | ||
} | ||
|
||
func testLoremIpsum() { | ||
app.buttons["Lorem Ipsum"].tap() | ||
XCTAssertTrue(app.textViews.firstMatch.waitForExistence(timeout: timeout), "Lorem Ipsum not loaded.") | ||
} | ||
|
||
func testNavigationTransaction() { | ||
app.buttons["Test Navigation Transaction"].tap() | ||
XCTAssertTrue(app.images.firstMatch.waitForExistence(timeout: timeout), "Navigation transaction not loaded.") | ||
} | ||
|
||
func testShowNib() { | ||
app.buttons["Show Nib"].tap() | ||
XCTAssertTrue(app.buttons["Button"].waitForExistence(timeout: timeout), "Show Nib not loaded.") | ||
} | ||
|
||
func testShowSwiftUI() { | ||
app.buttons["Show SwiftUI"].tap() | ||
XCTAssertTrue(app.staticTexts["SwiftUI!"].waitForExistence(timeout: timeout), "SwiftUI not loaded.") | ||
} | ||
|
||
private func waitForExistenseOfMainScreen() { | ||
XCTAssertTrue(app.buttons["captureMessage"].waitForExistence(timeout: timeout), "Home Screen doesn't exist.") | ||
} | ||
} |