Comments (16)
You're actually the second person to have asked for this.
I've been planning a "scenarios" feature for a while that will not only allow what you're asking for, but also allow you to switch whole scenarios on and off, and support simple (jMock-esque) state.
I'll roll it out incrementally, with this as the first step.
from wiremock.
So I can think of a scenario in JSON format for what I am thinking of:
{
"recordMappings": true,
"mappingsOutputDir": "somedir/relative/to/defautl/dir"
"filesOutputDir": "somedir/relative/to/defautl/dir"
}
What would you define a scenario as? Wrapping how the application records certain things, and specifying a definition file
for the application to use?
from wiremock.
I was thinking of making the scenario name the root dir and putting mappings, and __files under it, rather than specifying them separately.
e.g.
wiremock
scenario-1
mappings
__files
scenario-2
mappings
__files
So the command line would look something like:
java -jar wiremock-standalone.jar --proxy-all="http://somehost.com" --record-mappings --scenario="successful-login"
from wiremock.
Ahh cool, I see what you mean now, I like that approach better.
from wiremock.
Hey Ryan,
I'm guessing you're not too bothered about this now that you've moved on, so I'll close it off. Feel free to re-open if you'd still like something like this implemented.
Cheers,
Tom
from wiremock.
Sounds cool :-) Doing this locally now by just creating different subdirectories with __files and mappings in to accomplish the same sorta thing, just have to move the WireMock standalone jar which is a little annoying.
from wiremock.
I jumped the gun, just found --root-dir in the documentation: http://wiremock.org/running-standalone.html
Does this also work for recording, or just playback?
from wiremock.
Should be both, if memory serves.
from wiremock.
You're right, they both work! How did I not figure out this until today? Thanks Tom, this will make things a lot easier.
from wiremock.
Is this feature available now...?
I tried java -jar wiremock-standalone-2.10.1.jar --proxy-all="http://myhost.com" --record-mappings --scenario="successful"
and wiremock fails to start with below exception -
Exception in thread "main" joptsimple.UnrecognizedOptionException: scenario is not a recognized option at joptsimple.OptionException.unrecognizedOption(OptionException.java:108) at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510) at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56) at joptsimple.OptionParser.parse(OptionParser.java:396) at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.<init>(CommandLineOptions.java:135) at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:52) at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:113)
from wiremock.
Not really sure what you're trying to do here, but there's never been any plan to add a scenario
CLI parameter. I'd also suggest trying the new record feature as you're using the legacy one there which is less flexible.
from wiremock.
I just started using WireMock and looking to use one mock service for multiple service needs. For the sake of maintainability, I thought of having files and mappings in corresponding sub directories.
I remember reading in some forum that wiremock supports subdirectory structure. Looking for ways to achieve that.
from wiremock.
Use the root-dir
command line param to use files and mappings in another directory.
from wiremock.
That sort of helped. Thanks.
Does WireMock support driving responses based on "x-Correlation-Id" ..?
from wiremock.
If that is a header, you can match headers. Check out the docs: http://wiremock.org/docs/request-matching/
from wiremock.
This worked great for my need. Thanks a bunch!!! I might sound silly, but one last thing for a dummy like me.
I have mapping for multiple services on same folder and different service returns its own response based on the correlation id. I want to have a separate file for each service, that returns a specific response when the predefined correlation IDs doesn't match. A detailed example below.
map "app1-corId1" returns file "app1-corId1" as response on matching corId1 and url
map "app1-corId2" returns file "app1-corId2" as response on matching corId2 and url
map "app2-corId3" returns file "app2-corId3" as response on matching corId3 and url
map "app2-corId4" returns file "app2-corId4" as response on matching corId4 and url
I want to return file "app1-anyCorId" on matching the url on corId mismatch and no corId cases. I tried by adding priority 10 and removing header matching from request, but it fails to bring up the mock service. Is there a way to achieve this...?
from wiremock.
Related Issues (20)
- Update org.xmlutil:xmlunit-core to Version 2.10.0 HOT 2
- Introduce a GUI for open source HOT 1
- NPE on WireMockServer.getServeEvents when using a StubRequestFilter HOT 1
- Adding more jettyAcceptors seems to do nothing besides cause thread contention. HOT 1
- align new join handlebar helper with features present in the join provided in the library, but not covered yet
- Expose args in Options so extensions can read it
- Possible memory leak ? HOT 15
- Prevent creating multiple stub mappings with the same ID HOT 1
- Support virtual threads in Jetty server for standalone deploy
- Error when proxying to a host that is only accessible via IPv6 HOT 1
- Formatted dates not in UTC
- __files created by default since v3.6.0 HOT 1
- absent operand must be a non-null string
- Array and data manipulation in handlebars template when using docker
- FileItemPartAdapter returning multipart's field name instead of a filename
- Avoiding reading zipfile entries repeatedly in ClasspathFileSource
- Support disabled state for stub mappings HOT 1
- Add a unique id to the template request model
- Add self-description callback(s) to MatchResult for use in Diff
- Report webhook errors and results as sub-events
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wiremock.