Add support for recording multiple network calls in one test run
czechboy0 opened this issue · comments
Since Cassette
saves an array of Interaction
s, 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
calledrecordMultiple
, which would allow for not stopping after the firstInteraction
has been recorded - add a method on
Session
calledfinishRecording()
, which persists allInteraction
s from memory to disk and asserts to present the file path, like it does now.finishRecording()
would only have to be called ifrecordMultiple
is set totrue
- maybe even call
finishRecording()
fromdeinit
ofSession
, 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 prerecordedInteraction
s 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
).
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. 👍