venmo / DVR

Network testing for Swift
http://blog.soff.es/network-testing-in-swift-with-dvr
MIT License
651 stars 86 forks source link

Not recording any files? #57

Closed JanGorman closed 8 years ago

JanGorman commented 8 years ago

Hey there,

love the idea of the library but I just cannot get it record anything. What am I missing? Tried injecting the session all the way to where it was used which didn't do anything so I took a step back and just tried recording the session directly. Which again didn't do anything:

let session = Session(cassetteName: "example")
let task = session.dataTaskWithURL(NSURL(string: "https://api.dailymotion.com/video/x26m1j4")!) { _, _, _ in
}
task.resume()

Also tried dataTaskWithRequest but same difference. The test always passes.

Looking at the README I would expect it to fail with assert: "… with path of the recorded file. …"

Put together a sample: https://github.com/JanGorman/DVRSample

JanGorman commented 8 years ago

Ok, I get it. I need to run this with waitForExpectationsWithTimeout. Maybe could be improved in the documentation?

For a lot of uses cases this isn't really feasible. e.g. I have a class that I inject a datasource to and this class does something with the completion block. But the test never sees the block so there's no way to call expecation.fulfill() in the test itself. I guess fall back to a blocking while in those cases…