Skip to content

Commit 65f8d3a

Browse files
Add different contexts to test app orientation
- use Quick SharedExamples to avoid repeating code
1 parent 328c296 commit 65f8d3a

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

SwiftWeatherUITests/SwiftWeatherUITests.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,33 @@ class SwiftWeatherUITests: QuickSpec {
1414

1515
beforeSuite {
1616
self.continueAfterFailure = false
17-
XCUIDevice.shared().orientation = .portrait
17+
1818
app.launch()
1919
}
2020

2121
describe("a wheather viewcontroller") {
22+
context("when the app orientation is portrait") {
23+
beforeEach {
24+
XCUIDevice.shared().orientation = .portrait
25+
}
26+
itBehavesLike("a regular wheather viewcontroller")
27+
}
28+
29+
context("when the app orientation is landscape") {
30+
beforeEach {
31+
XCUIDevice.shared().orientation = .landscapeLeft
32+
}
33+
itBehavesLike("a regular wheather viewcontroller")
34+
}
35+
}
36+
}
37+
}
38+
39+
class RegularWheatherViewControllerConfiguration: QuickConfiguration {
40+
override class func configure(_ configuration: Configuration) {
41+
let app = XCUIApplication()
42+
43+
sharedExamples("a regular wheather viewcontroller") { (context: SharedExampleContext) in
2244
it("shows city") {
2345
expect(app.staticTexts["a11y_current_city"].exists).to(beTruthy())
2446
}
@@ -32,5 +54,5 @@ class SwiftWeatherUITests: QuickSpec {
3254
}
3355
}
3456
}
35-
3657
}
58+

0 commit comments

Comments
 (0)