venmo / DVR

Network testing for Swift

Home Page:http://blog.soff.es/network-testing-in-swift-with-dvr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for recording multiple network calls in one test run

czechboy0 opened this issue · comments

Since Cassette saves an array of Interactions, instead of just one, it would be great to add support for recording and replaying multiple interactions in one test case.

Possible changes for recording:

  • add a property on Session called recordMultiple, which would allow for not stopping after the first Interaction has been recorded
  • add a method on Session called finishRecording(), which persists all Interactions from memory to disk and asserts to present the file path, like it does now. finishRecording() would only have to be called if recordMultiple is set to true
  • maybe even call finishRecording() from deinit of Session, so that user doesn't have to call it manually

Possible changes for replaying:

  • keep counter of which Interaction should be played next, automatically increment after each replay
  • assert on deinit that exactly the number of prerecorded Interactions has been called (fail the test if more or less network calls were made)

???

Profit.

Been thinking about this a lot too since first writing all of this. I was thinking it could work like UITableView stuff. So you can call insertRow... by itself to just insert one animated or you can use beginEditing & endEditing to group them together. This way, we don't break the current API and you can do multiple. Thoughts? cc @ayanonagon @hyperspacemark

I def like the idea of not breaking the current API and modeling it after something that is familiar to most Cocoa developers (like UITableView). :octocat:

It looks like we will always need two variables/calls. In my suggestion above, it was recordMultiple and finishRecording(), in your case it could be startBatchRecording and endBatchRecording. I probably like your solution better, though. 👍