-
-
Notifications
You must be signed in to change notification settings - Fork 314
Expand file tree
/
Copy pathWeatherUITests.swift
More file actions
75 lines (59 loc) · 2.43 KB
/
Copy pathWeatherUITests.swift
File metadata and controls
75 lines (59 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// WeatherUITests.swift
// WeatherUITests
//
// Created by Cameron on 30/04/2026.
//
import XCTest
final class WeatherUITests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
@MainActor
func testLocationPickerOpens() throws {
let app = launchApp()
XCTAssertTrue(app.staticTexts["San Francisco"].waitForExistence(timeout: 5))
app.buttons["weather.locationButton"].tap()
XCTAssertTrue(app.staticTexts["Locations"].waitForExistence(timeout: 2))
}
@MainActor
func testSettingsSheetOpens() throws {
let app = launchApp()
XCTAssertTrue(app.staticTexts["San Francisco"].waitForExistence(timeout: 5))
app.buttons["weather.settingsButton"].tap()
XCTAssertTrue(app.staticTexts["Settings"].waitForExistence(timeout: 2))
}
@MainActor
func testPrecipitationDetailOpens() throws {
let app = launchApp()
XCTAssertTrue(app.staticTexts["San Francisco"].waitForExistence(timeout: 5))
let precipitationCard = app.buttons["weather.precipitationCard"]
let mainScrollView = app.scrollViews["weather.mainScrollView"]
XCTAssertTrue(mainScrollView.waitForExistence(timeout: 2))
for _ in 0..<5 where !precipitationCard.exists {
mainScrollView.swipeUp()
}
XCTAssertTrue(precipitationCard.waitForExistence(timeout: 1))
precipitationCard.tap()
XCTAssertTrue(app.staticTexts["PRECIPITATION"].waitForExistence(timeout: 2))
}
@MainActor
func testLaunchPerformance() throws {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
_ = launchApp()
}
}
@MainActor
private func launchApp() -> XCUIApplication {
let app = XCUIApplication()
app.launch()
return app
}
}