Using XCTest's XCTWaiter class, I would like to check on a predicate, namely:
NSPredicate(format: "hittable == true") in an XCTNSPredicateExpectation expectation in
open
class func wait(for expectations: [XCTestExpectation], timeout seconds: TimeInterval, enforceOrder enforceOrderOfFulfillment: Bool) -> XCTWaiterResult`
I would like to verify this predicate in multiple XCTestExpectation expectations. I think this is the most time efficient way to check that multiple elements on a particular screen are hittable.
I discovered that the combination of using the hittable predicate on an array with more than one expectations results in the error
`Assertion Failure: <unknown>:0: Neither attributes nor error returned`
If I use the exists predicate, the verification of an array of expectations in wait(for:timeout:enforceOrder:) works well. Also, if the array of expectations contains just one expectation, the verification works fine in combination with the hittable predicate.
Here is a test method that shows the issue if you run it in an XCTestCase subclass, you need to adjust the identifiers to something on your app that is hittable at the same time on a screen:
func testAssertThatMultipleElementsAreHittable() {
let accessibilityIdentifiers = ["lapTimer", "eventTimer", "startButton", "stopButton"]
let predicate = NSPredicate(format: "hittable == true") //fails with hittable, but passes with exists!
var expectations = [XCTNSPredicateExpectation]()
accessibilityIdentifiers.forEach { (identifier) in
expectations.append(XCTNSPredicateExpectation(predicate: predicate, object: XCUIApplication().descendants(matching: .any)[identifier]))
}
let result = XCTWaiter.wait(for: expectations, timeout: 5.0, enforceOrder: false)
if result != .completed {
XCTFail("waiting failed!")
}
}
Do you have an idea what is going on here?