File tree Expand file tree Collapse file tree 2 files changed +34
-27
lines changed Expand file tree Collapse file tree 2 files changed +34
-27
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class WeatherViewController: UIViewController {
2323 super. viewDidLoad ( )
2424 viewModel = WeatherViewModel ( )
2525 viewModel? . startLocationService ( )
26+ setA11yIdentifiers ( )
2627 }
2728
2829 override func viewWillAppear( _ animated: Bool ) {
@@ -108,4 +109,13 @@ class WeatherViewController: UIViewController {
108109 }
109110 }
110111 }
111- }
112+
113+ //MARK: Accessibility
114+ func setA11yIdentifiers( ) {
115+ locationLabel. accessibilityIdentifier = " a11y_current_city "
116+ iconLabel. accessibilityIdentifier = " a11y_wheather_icon "
117+ temperatureLabel. accessibilityIdentifier = " a11y_wheather_temperature "
118+ }
119+
120+
121+ }
Original file line number Diff line number Diff line change 44//
55
66import XCTest
7+ import Quick
8+ import Nimble
79
8- class SwiftWeatherUITests : XCTestCase {
10+ class SwiftWeatherUITests : QuickSpec {
911
10- override func setUp( ) {
11- super. setUp ( )
12-
13- // Put setup code here. This method is called before the invocation of each test method in
14- // the class.
15-
16- // In UI tests it is usually best to stop immediately when a failure occurs.
17- continueAfterFailure = false
18- // UI tests must launch the application that they test. Doing this in setup will make sure
19- // it happens for each test method.
20- XCUIApplication ( ) . launch ( )
21- }
22-
23- override func tearDown( ) {
24- // Put teardown code here. This method is called after the invocation of each test method
25- // in the class.
26- super. tearDown ( )
27- }
28-
29- func testApp( ) {
12+ override func spec( ) {
3013 let app = XCUIApplication ( )
31- testNumberOfElements ( app)
32- }
3314
34- /* Actually test that images load...might want to find a more exact way of doing this... */
35- func testNumberOfElements( _ app: XCUIApplication ) {
36- assert ( app. staticTexts. count > 0 )
15+ beforeSuite {
16+ self . continueAfterFailure = false
17+ XCUIDevice . shared ( ) . orientation = . portrait
18+ app. launch ( )
19+ }
20+
21+ describe ( " a wheather viewcontroller " ) {
22+ it ( " shows city " ) {
23+ expect ( app. staticTexts [ " a11y_current_city " ] . exists) . to ( beTruthy ( ) )
24+ }
25+
26+ it ( " shows wheather icon " ) {
27+ expect ( app. staticTexts [ " a11y_wheather_icon " ] . exists) . to ( beTruthy ( ) )
28+ }
29+
30+ it ( " shows wheather temperature " ) {
31+ expect ( app. staticTexts [ " a11y_wheather_temperature " ] . exists) . to ( beTruthy ( ) )
32+ }
33+ }
3734 }
3835
3936}
You can’t perform that action at this time.
0 commit comments