Mercurial > public > simoleon
comparison SimoleonUITests/SimoleonUITests.swift @ 93:529feb1fc8d5
Added UI Tests for capture screenshots
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 03 Aug 2021 12:33:32 +0100 |
parents | 879e20d2a837 |
children | fa994172c050 |
comparison
equal
deleted
inserted
replaced
92:8386dbf80047 | 93:529feb1fc8d5 |
---|---|
9 | 9 |
10 class SimoleonUITests: XCTestCase { | 10 class SimoleonUITests: XCTestCase { |
11 | 11 |
12 override func setUpWithError() throws { | 12 override func setUpWithError() throws { |
13 // 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. |
14 | |
14 | 15 |
15 // In UI tests it is usually best to stop immediately when a failure occurs. | 16 // In UI tests it is usually best to stop immediately when a failure occurs. |
16 continueAfterFailure = false | 17 continueAfterFailure = false |
17 | 18 |
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. | 19 // 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. |
20 | 21 |
21 override func tearDownWithError() throws { | 22 override func tearDownWithError() throws { |
22 // Put teardown code here. This method is called after the invocation of each test method in the class. | 23 // Put teardown code here. This method is called after the invocation of each test method in the class. |
23 } | 24 } |
24 | 25 |
25 // MARK: - Tab View | 26 // MARK: - Automate screenshots |
26 func testExample() throws { | 27 func testScreenshots() throws { |
27 let app = XCUIApplication() | 28 let app = XCUIApplication() |
28 setupSnapshot(app) | 29 setupSnapshot(app) |
30 | |
31 // MARK: - Launch | |
29 app.launch() | 32 app.launch() |
30 snapshot("01LoginScreen") | 33 snapshot("0-Launch") |
31 | 34 |
35 // MARK: - Remove 100 from conversion textfield and type custom amount | |
36 let conversionTextfield = app.textFields["ConversionTextfield"] | |
37 conversionTextfield.tap() | |
38 for _ in (0..<4) { | |
39 conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue) | |
40 } | |
41 conversionTextfield.typeText("1470.10") | |
42 snapshot("1-Convert") | |
43 | |
44 // Remove custom amount and type again 1000 | |
45 for _ in (0..<7) { | |
46 conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue) | |
47 } | |
48 conversionTextfield.typeText("1000\n") | |
49 | |
50 // MARK: - Open currency selector, search BTC, and select first row | |
51 app.buttons["CurrencySelector"].tap() | |
52 snapshot("2-CurrencySelector") | |
53 | |
54 let searchBar = app.textFields["SearchBar"] | |
55 searchBar.tap() | |
56 searchBar.typeText("BTC") | |
57 app.buttons["CurrencyRow"].firstMatch.tap() | |
58 snapshot("3-Bitcoin") | |
59 | |
60 // MARK: - Go to favorites | |
61 conversionTextfield.typeText("\n") // Dismiss keyboard | |
62 app.tabBars.buttons.element(boundBy: 1).tap() | |
63 snapshot("4-Favorites") | |
32 } | 64 } |
33 | 65 |
34 func testLaunchPerformance() throws { | 66 func testLaunchPerformance() throws { |
35 if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { | 67 if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { |
36 // This measures how long it takes to launch your application. | 68 // This measures how long it takes to launch your application. |