Open andy-tarr opened 1 year ago
Thank you Andy, that is a standing feature.
What do you think something like this:
testPlan(
threadGroup(1, 1,
httpCookies()
.add(new Cookie("MyCookie", "val")
.domain("myservice.com")
.path("/users")
.secure(true)
.expires(Instant.now().plusSeconds(30))
)
httpSampler("http://myservice.com"),
)
).run();
We could internally implement it with a jsr 223 sampler, and would have the advantage, over JMeter cookies manager way of setting cookies, that you can directly control at what point in test plan you actually want the cookies to be set. This would avoid cookies being set in requests which shouldn't (and may make the test plan behave in unexpected way) or require some workaround, like adding a controller, to limit the scope of the cookie manager to get a similar effect.
We could even in the future use same approach add methods to remove some particular cookie, or explicitly clear all cookies.
I think this approach looks great
Add support to the cookie manager to create custom cookies