jeffbski / bench-rest

bench-rest - benchmark REST (HTTP/HTTPS) API's. node.js client module for easy load testing / benchmarking REST API's using a simple structure/DSL can create REST flows with setup and teardown and returns (measured) metrics.
MIT License
303 stars 51 forks source link

Dependent flow actions #16

Closed danielabar closed 9 years ago

danielabar commented 9 years ago

Is it possible to make the flow actions dependent on each other? I'm trying to write a test where the output of one request is used as the input to the next request. For example:

  1. POST /user
  2. Get the returned user id from step 1 and use that to POST /foo etc.
jeffbski commented 9 years ago

Yes, you can certainly do that by adding hooks.

There are a few built-in hooks that save and use an etag, but you can also just create functions to do whatever you want.

See this example and hopefully it will give you some ideas

https://github.com/jeffbski/bench-rest/blob/master/examples/hooks.js

danielabar commented 9 years ago

First I tried defining a variable outside the flow, and populating it in the hooks, then using it in the json for the post, but that didn't work, it remained undefined.

Then got it working by populating all.requestOptions.json in the hooks.

Thanks for your help!

jeffbski commented 9 years ago

excellent! I'm glad you were able to get it working.