When I write this:
func testMock() {
class MockAPI: API {
var expectation: XCTestExpectation?
init(expectation: XCTestExpectation) {
self.expectation = expectation
}
override func method() {
expectation!.fulfill()
}
}
let mockAPI = MockAPI(expectation: self.expectationWithDescription("API: method should be called"))
...
self.waitForExpectationsWithTimeout(1, handler: nil)
}
I get the error: Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
Any ideas?
Just to clarify a little, since OCMock doesn't work with swift, I'm trying to replicate the mock behavior described here NSHipster / Test (it's at the end of the blog post).
Something else worth mentioning is that initially what I wanted was:
func testMock() {
let expectation = self.expectationWithDescription("API: method should be called")
class MockAPI: API {
override func method() {
expectation.fulfill()
}
}
let mockAPI = MockAPI()
...
self.waitForExpectationsWithTimeout(1, handler: nil)
}
But I was getting "SourceKitService Crashed", similar to this problem I think SourceKitService Terminated