Sample Test Class

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page 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)
    }
}