Sample Test Class
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.startScanSession(apiKey: "<DEQUE_APIKEY>",
projectId: "<DEVHUB_PROJECT_ID>")
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)
}
override class func tearDown() {
do {
// Write a self-contained HTML report to a specified directory
let report = try axe?.generateHtmlReportAndSummary()
print("Report saved to: \(report?.htmlReportPath ?? "unknown")")
} catch {
print("Failed to generate report: \(error)")
}
}
}