Cast from 'XCUIElement' to unrelated type 'NSArray' always fails

Losing my mind here, XCode 7 GM here trying to parse a nested array inside a json dictinoary and get back :


Cast from 'XCUIElement' to unrelated type 'NSArray' always fails


This inside a Unit test, and the code wrorks fine inside non unit test / running code.


if let categories = articleDict[Article.ArticleKeys.CategoriesArray.rawValue] as? [[String: AnyObject]] {

I have the same exact problem. Here is an example of the code that generates these warnings in my current project:


if let dataInfo = JSON["attribute"] as? [String:AnyObject]{


It seems that some of my tests are then broken due to this issue.

Any useful hint?

Same here, using the release version of Xcode 7.0.1 (Version 7.0.1 (7A1001))


Same code works fine in my app target... only produces this warning in my tests.

Aren't you using AnyObject values? Current Swift shows (seemingly) odd behaviors when subscripting directly to AnyObject values, and that behavior depends on what frameworks you import. Without getting more info, I cannot say any more.

Cast from 'XCUIElement' to unrelated type 'NSArray' always fails
 
 
Q