So I added a Response Assertion on the main sample and apply to that and all sub-samples. I assert its a good Response Code, so the assertion will fail Response codes like 4xx and 5xx errors. I'm curious, I store a user_id in a jmeter variable when a new user is created in my load script (which is available in jmeter for the entire thread/samplers/session)... Is there anyway i can output that variable via the Beanshell for All sampler requests ONLY IF there is an Error.
I already output user_id earlier for ALL requests right after creating a user via something like so:
log.info("user_id:"+ vars.get("user_id") ); //gotten via JSON Path PostProcessor earlier when creating User.
But I'd like do output something like so for all Response Assertion errors:
log.info("Response Assertion failure for user_id:"+ vars.get("user_id") );
maybe a 'BeanShell Post Processor' but dont really have a good idea how to hook that into the 1 Response Assertion whick checks the whole Thread Group so it only outputs to the log the user_id dynamically if there is Assertion failure.
Is there a worst case scenario, where I cant do it for all requests at the 'top level' of the Thread Group... but maybe I'd have to add Response Assertions on each request instead and only then I can dynamically add the output somehow? (But if there is a way of doing it once for all requests would be cool/better) Any ideas are welcome, Thanks!

