BeanShell Assertion for multiple sub-results in JMeter

Words
60
Reading
1 min
Listen
Play
8y

You can use standard "Response Assertion" or other CSS or XPath assertions to check your JMeter requests' responses.

But, if there are situations such redirection, there will multiple responses for each request. In case of you need to check all that sub results, standard assertions can't provide any easy solution.

An optimized solution is to use BeanShell Assertion:

Subresults = SampleResult.getSubResults();
int numOfsubResult = Subresults.length;

print("Num of sub results: " + numOfsubResult);

for(int i =0; i<numOfsubResult; i++){
    print(Subresults[i].getResponseCode());
    print(Subresults[i].getURL().getPath());
    print(Subresults[i].getUrlAsString());
}


BeanShell Assertion for multiple sub-results in JMeter | Ecency