I am new to jmeter and would like to know if it is possible to call a custom assertion message from a central location.
Thread group 1
http sample
xpath extraction
custom assertion message
Thread group 2
http sample 1
xpath extraction
custom assertion message
http sample 2
xpath extraction
custom assertion message
The custom message use the xpath extraction to get the response code, if the success message code returned then the custom message is ignored.
If the response code is not a success response, we extract the actual response code and use in the custom assertion message.
I would like to call the custom message from one central location instead.
The custom assertion is below:
if (!"SuccessResponseCode".equals(vars.get("xpathResponseCode")) && prev_result != null){
AssertionResult.setFailure(true);
AssertionResult.setFailureMessage("The response code is "+vars.get("xpathextractionResponseCode").toString()+" and the expected is expectedResponseCode"+ctx.getThreadGroup().getName()+" test case.");
}
So I would like to call an external custom message
Custom assertion
Thread group 2 http sample 1 xpath extraction JS232 - call custom message http sample 2 xpath extraction JS232 - call custom message
Just put your Assertion at the same level as Thread Groups.
Assertions follow JMeter Scoping Rules so this way a single assertion will be applied to all samplers in its scope: