Sample Test Class

Link to Sample Test Class copied to clipboard
Not for use with personal data
import axeDevToolsXCUI
import XCTest

class MyUITests: XCTestCase {
    var axe: AxeDevTools?
    var app = XCUIApplication()

    override func setUpWithError() throws {
        axe = try AxeDevTools.login(withAPIKey: "<DEQUE_APIKEY>")

        app.launch()
    }

    func testAccessibility() throws {
        guard let result = try axe?.run(onElement: app) else {
            XCTFail()
            return
        }

        // Send results to the dashboard in case of a failure.
        if result.failures.count > 0 {
            try axe?.postResult(result)
        }

        // Fail the build if failures were found
        XCTAssertEqual(result.failures.count, 0)
    }
}