1

Is there a way to make a request on JMeter and receive a mocked JSON response that I create, for example:

[
 {
   "Car": "BMW",
   "Model": "520D",
   "Color": "Black"
 },
 {
   "Car": "Audi",
   "Model": "A3",
   "Color": "Red"
 },
 {
   "Car": "Ford",
   "Model": "Focus",
   "Color": "Blue"
 }
]

I need a mocked up response that I can practice on using JMeter samplers etc.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
Jaff
  • 155
  • 1
  • 4
  • 14

1 Answers1

1

If you want to mock the entire request/response use Dummy Sampler, just set Response Data field with your JSON and it'll return it:

If you want to mock only the response, meaning send to a real server the request, see mock http request answer Which suggests using a third party, as WireMock or mock-server.com as @Kiril S. suggested in comments

Another option is to manipulate response using JSR223 PostProcessor

Use SampleResult.setResponseData to set JSON, for example:

prev.setResponseData("[ {   \"Car\": \"BMW\" }]","UTF-8");
Ori Marko
  • 56,308
  • 23
  • 131
  • 233