question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New stub mapping record/playback feature

See original GitHub issue

Problem

WireMock’s record feature seems to be one of the most heavily used, and as such it is quite frequently the subject of feature requests. Rather than apply lots of spot fixes for specific cases, I propose re-writing the record feature from scratch, incorporating general solutions to the types of problems expressed here and on the mailing list.

Based on past questions and requests related to the recorder, I’d like to suggest it attempts to achieve the following things:

  • Record and playback without having to restart in between.
  • Customise output: file naming, request/response headers/body transformation.
  • Filter what gets recorded.
  • Statefulness - support a succession of responses for the same request (rather than just ignoring subsequent responses as is currently the case)
  • Choose target - in memory, persisted, downloaded
  • Potential to import from other formats e.g. HAR, RAML (but not necessarily immediate support)

Update It looks like more flexibility in how body patterns are recorded would also be useful. The current behaviour when the request body is JSON is to do a non-strict semantic equality match. Being able to specify the parameters passed to this or override it with e.g. a JSONPath match for a single element would probably be helpful in many cases.

Solution

I propose the following solution based on these objectives:

Snapshot recording - make some requests (that get captured in the request journal) then hit a “capture snapshot” API. This avoids the stop/start problem.

Recording parameters Optional filtering and transformation parameters could be passed into the API call, in addition to a save/download flag. This could include an indication of how to match request bodies.

Use Scenarios for multiple identical requests - when more than one instance of a request is seen, capture each under one scenario so that the progression of responses seen originally is played back.

Recording transformer extension point - expose a Java interface that (similar to ResponseDefinitionTransformer) supports custom transformations of stub mappings as they’re recorded.

Recording adapter extension point - expose a Java API to the recorder which is sufficiently generic that other formats can be adapted to it e.g. Swagger/RAML or HAR.

Now that it’s possible to add admin API routes, an option would be to implement this as an extension, and therefore incubate in in a separate project.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
selangleycommented, Feb 9, 2017

Looks to be very compatible with the operations I proposed in my pull request last year:

https://github.com/tomakehurst/wiremock/pull/400 Added ability to record a particular request/response repeatedly

so I’m all for this solution.

0reactions
MasonMcommented, May 30, 2017

For those following this issue: I just entered PR #674 to integrate wiremock-snapshot into wiremock

Read more comments on GitHub >

github_iconTop Results From Across the Web

Record and Playback an API to Create a Mock - WireMock
Record and Playback. WireMock can create stub mappings from requests it has received. Combined with its proxying feature this allows you to “record”...
Read more >
Wiremock Stubbing, Stub Verification And Proxying With ...
Wiremock provides a recorder interface to record or capture stub mappings by proxying through an actual URL. This is helpful to create mappings...
Read more >
Can WireMock play and record be used at the same time?
1) You can use the --proxy-all parameter and not --record-mappings when playing back. This will cause any request unmatched by an existing stub...
Read more >
wiremock-snapshot/README.md at master · MasonM/wiremock ...
DEPRECATED: Wiremock extension for recording stub mappings ... It's an alternative to the Record and Playback feature that doesn't require restarting the ...
Read more >
Recording Stubs | MockLab
If the API you're mocking already exists you can speed up the process of stubbing responses using MockLab's record feature. This essentially involves...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found