Mercurial > public > simoleon
comparison SimoleonUITests/SimoleonUITests.swift @ 109:587924519d3b
Reestructured schemes and targets
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Thu, 05 Aug 2021 09:39:19 +0100 |
parents | 599fe95307f6 |
children | 9439c76e6590 |
comparison
equal
deleted
inserted
replaced
108:9f9fa45c9ef6 | 109:587924519d3b |
---|---|
6 // | 6 // |
7 | 7 |
8 import XCTest | 8 import XCTest |
9 | 9 |
10 class SimoleonUITests: XCTestCase { | 10 class SimoleonUITests: XCTestCase { |
11 var screnshotEndingName = "" | |
12 | 11 |
13 override func setUpWithError() throws { | 12 override func setUpWithError() throws { |
14 // Put setup code here. This method is called before the invocation of each test method in the class. | 13 // Put setup code here. This method is called before the invocation of each test method in the class. |
15 if UIDevice.current.userInterfaceIdiom == .pad { | |
16 XCUIDevice.shared.orientation = .landscapeLeft | |
17 screnshotEndingName = "-force_landscapeleft" | |
18 } | |
19 | |
20 let app = XCUIApplication() | |
21 setupSnapshot(app) | |
22 app.launch() | |
23 | 14 |
24 // In UI tests it is usually best to stop immediately when a failure occurs. | 15 // In UI tests it is usually best to stop immediately when a failure occurs. |
25 continueAfterFailure = false | 16 continueAfterFailure = false |
26 | 17 |
27 // 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. | 18 // 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. |
28 } | 19 } |
29 | 20 |
30 override func tearDownWithError() throws { | 21 override func tearDownWithError() throws { |
31 // Put teardown code here. This method is called after the invocation of each test method in the class. | 22 // Put teardown code here. This method is called after the invocation of each test method in the class. |
32 } | 23 } |
33 | 24 |
34 // MARK: - Automate screenshots | 25 |
35 func testLaunch() { | 26 func testLaunchPerformance() throws { |
36 if UIDevice.current.userInterfaceIdiom == .pad { | 27 if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { |
37 XCUIApplication().tables.buttons.firstMatch.tap() | 28 // This measures how long it takes to launch your application. |
29 measure(metrics: [XCTApplicationLaunchMetric()]) { | |
30 XCUIApplication().launch() | |
31 } | |
38 } | 32 } |
39 | |
40 snapshot("1Launch\(screnshotEndingName)") | |
41 } | 33 } |
42 | |
43 func testCurrencySelector() { | |
44 if UIDevice.current.userInterfaceIdiom == .pad { | |
45 XCUIApplication().tables.buttons.firstMatch.tap() | |
46 } | |
47 | |
48 XCUIApplication().scrollViews.buttons.firstMatch.tap() | |
49 snapshot("2CurrencySelector\(screnshotEndingName)") | |
50 | |
51 XCUIApplication().tables.buttons.element(boundBy: 6).tap() | |
52 let conversionTextfield = XCUIApplication().textFields.firstMatch | |
53 conversionTextfield.tap() | |
54 for _ in (0..<4) { | |
55 conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue) | |
56 } | |
57 | |
58 conversionTextfield.typeText("\n") | |
59 | |
60 snapshot("3Amount\(screnshotEndingName)") | |
61 } | |
62 | |
63 func testFavorites() throws { | |
64 // Go to favorites | |
65 if UIDevice.current.userInterfaceIdiom == .pad { | |
66 XCUIApplication().tables.buttons.element(boundBy: 1).tap() | |
67 } else { | |
68 XCUIApplication().tabBars.buttons.element(boundBy: 1).tap() | |
69 } | |
70 | |
71 snapshot("4Favorites\(screnshotEndingName)") | |
72 } | |
73 | |
74 // func testLaunchPerformance() throws { | |
75 // if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { | |
76 // // This measures how long it takes to launch your application. | |
77 // measure(metrics: [XCTApplicationLaunchMetric()]) { | |
78 // XCUIApplication().launch() | |
79 // } | |
80 // } | |
81 // } | |
82 } | 34 } |