I am starting to pick up XCUITest and I am running into an issue. I know a little about Objective-C / Swift. Enough that I have built a simply CRUD app in the past. The issue I am running into is outlined below.
I believe this has to do with declaring this and a class existing, but I am not 100% sure what I am missing here. Please go gentle on me. I have included my code below as well.
class CandySearchUITests: CandySearchUITestsLaunchTests {
func testTapOnChocolateBarItem() throws {
// Asset Candy Search Logo Exists (Acessibility Identifier)
XCTAssertTrue(app.images["candySearchLogo"].exists)
// Tap Chocolate Bar item (Table - Static Text)
app.tables.staticTexts["Chocolate Bar"].tap()
// Assert it landed on the Chocolate page (Navigation Bar - Static Test)
let chocolateNavigationBar = app.navigationBars["navigationBar"]
XCTAssertTrue(chocolateNavigationBar.staticTexts["Chocolate"].exists)
// Assert Chocolate Bar title exists (Static Text)
XCTAssertTrue(app.staticTexts["Chocolate Bar"].exists)
// Return to Candy Search Screen (Button)
chocolateNavigationBar.buttons["Back"].tap()
// Assert Candy Search Logo exists (Accessibility Identifier)
XCTAssertTrue(app.images["candySearchLogo"].exists)
}
}
I also noticed that I am getting 'Inheritance from a final class 'CandySearchUITestLaunchTests' however, I know why I was getting that error. That has been resolved.
Included my code from CandySearchUITestLaunchTests
import XCTest
class CandySearchUITestsLaunchTests: XCTestCase {
override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
override func setUpWithError() throws {
continueAfterFailure = false
}
func testLaunch() throws {
let app = XCUIApplication()
app.launch()
// Insert steps here to perform after app launch but before taking a screenshot,
// such as logging into a test account or navigating somewhere in the app
let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
}```