Mercurial > public > simoleon
view 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 |
line wrap: on
line source
// // SimoleonUITests.swift // SimoleonUITests // // Created by Dennis Concepción Martín on 08/07/2021. // import XCTest class SimoleonUITests: 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. } // MARK: - Automate screenshots func testScreenshots() throws { let app = XCUIApplication() setupSnapshot(app) // MARK: - Launch app.launch() snapshot("0-Launch") // MARK: - Remove 100 from conversion textfield and type custom amount let conversionTextfield = app.textFields["ConversionTextfield"] conversionTextfield.tap() for _ in (0..<4) { conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue) } conversionTextfield.typeText("1470.10") snapshot("1-Convert") // Remove custom amount and type again 1000 for _ in (0..<7) { conversionTextfield.typeText(XCUIKeyboardKey.delete.rawValue) } conversionTextfield.typeText("1000\n") // MARK: - Open currency selector, search BTC, and select first row app.buttons["CurrencySelector"].tap() snapshot("2-CurrencySelector") let searchBar = app.textFields["SearchBar"] searchBar.tap() searchBar.typeText("BTC") app.buttons["CurrencyRow"].firstMatch.tap() snapshot("3-Bitcoin") // MARK: - Go to favorites conversionTextfield.typeText("\n") // Dismiss keyboard app.tabBars.buttons.element(boundBy: 1).tap() snapshot("4-Favorites") } func testLaunchPerformance() throws { if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) { // This measures how long it takes to launch your application. measure(metrics: [XCTApplicationLaunchMetric()]) { XCUIApplication().launch() } } } }