Reputation: 43
I recently updated to the most recent version of Xcode (6.3) and are now unable to run our tests, which were previously functional.
It throws a SIGABRT with the following information:
Could not cast value of type 'MyApplication.MyPSClass' (0x109d7f410) to 'MyApplicationTests.MyPSClass' (0x1197ddec0).
MyApplicationTests is the Test Target and MyApplication is the normal application target.
MyApplication uses Parse as our back-end. Is it possible that this error is a result of the Subclassing functionality?
MyClass subclasses PFObject and PFSubclassing as is specified in the Parse's subclassing documentation:
class MyPSClass : PFObject, PFSubclassing { ... }
The line which shows the "Thread 1: SIGABRT" is:
let myPSInstance = MyPSClass.query().getObjectWithId("ParseObjectIDString") as! MyPSClass
The Test Class file, which contains this line, looks like this:
import UIKit
import XCTest
class MyClassTests: XCTestCase {
override func setUp() {
super.setUp()
//...
}
func testInit() {
let myPSInstance = MyPSClass.query().getObjectWithId("ParseObjectIDString") as! MyPSClass
//...
}
override func tearDown() {
super.tearDown()
}
}
Why is this happening and how can I fix it? Thanks in advance!
Upvotes: 4
Views: 1121
Reputation: 5536
What's happening is that in this line:
let myPSInstance = MyPSClass.query().getObjectWithId("ParseObjectIDString") as! MyPSClass
You're casting MyPSClass to MyApplicationTests.MyPSClass. You can't tell, because swift uses implicit namespaces (which hides the MyApplicationTests namespace). You can to use:
let myPSInstance = MyPSClass.query().getObjectWithId("ParseObjectIDString") as! MyApplication.MyPSClass
Upvotes: 0