Skip to content

Commit

Permalink
Capture map result on MainActor in elementCompoundOrPredicate
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Jarvis committed Nov 13, 2024
1 parent d8665c8 commit a57fcbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Example/ExampleUITests/XCUITestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class XCUITestCase: XCTestCase {
try app().descendants(matching: .any)
}

@MainActor
func elementPredicate(labeled label: String) -> NSPredicate {
NSComparisonPredicate(
leftExpression: NSExpression(forKeyPath: \XCUIElement.label),
Expand All @@ -31,11 +32,14 @@ class XCUITestCase: XCTestCase {
}

func elementCompoundOrPredicate(labeled labels: Set<String>) -> NSPredicate {
NSCompoundPredicate(orPredicateWithSubpredicates: labels.map(elementPredicate(labeled:)))
let subpredicates = labels.map { label in
elementPredicate(labeled: label)
}
return NSCompoundPredicate(orPredicateWithSubpredicates: subpredicates)
}

override func setUp() async throws {
DispatchQueue.main.async {
Task { @MainActor in
self._app = XCUIApplication()
self.continueAfterFailure = false
try? self.app().launch()
Expand Down

0 comments on commit a57fcbf

Please sign in to comment.