I'm currently writing tests for a small part of an OSX framework I'm working on. The tests are written using the packages Quick
and Nimble
. The test itself is very basic:
class OrderbookTestKraken: QuickSpec {
let kraken = Kraken()
override func spec() {
let coin = Coin(name: "DOGE", ask: 0.0, bid: 0.0, last: 0.0, bidSize: 0.0, askSize: 0.0)
describe("When an order book is requested") {
it("it should create an orderbook successfully") {
self.kraken.getOrderbook(coin: coin) { (error, orderbook) in
expect(orderbook).notTo(beNil())
}
}
}
}
}
And whenever I run it, the test instantly passes. Even though there's:
1) A breakpoint in the method getOrderbook
of my Kraken
instance.
2) nil
being returned in the orderbook
variable that's being used in the expect
statement.
The getOrderbook
method looks like this:
func getOrderbook(coin: Coin, onCompletion: @escaping (Error?, Orderbook?) -> Void) {
Alamofire.request("\(publicApiUrl ?? "")/Depth",
method: .get,
parameters: ["pair": "\(coin.name)XBT", "count": 3],
encoding: URLEncoding.default,
headers: nil).validate().responseJSON { response in
// There's a breakpoint here.
onCompletion(nil, nil)
}
}
So, it always returns nil
in the callback, and there's an untriggered breakpoint, but the test always succeeds. When I tried some caveman debugging, and put a breakpoint above the Alamofire
request, the breakpoint did get triggered.
Is this some known issue, or is It something I'm overseeing?
Thanks.