I have the JMeter script in the below format.
The thing here is, once i send the write request to server, the response can come in variable number of read responses. The first 4 read responses are fixed but after that the number of read responses vary on the server busy times. If the server is very busy it will keep sending small chunks of data in a pair of 2 read responses. That is the reason i have kept it in a while controller looping till the end of the response.
Now, for Asserting this response, i check for the string in a postprocessor and save the output into a JMeter variable.
I finally check the Variable values in a "JSR223 Sampler". If i place a JSR223 Assertion, it applies to only first 4 read responses and ignores the responses under While Controller. Problem i'm facing, the error is not getting reported if the text check fails. However, it is ending the iteration and starting a new one.
JSR223 PostProcessor 1
String id=prev.getResponseDataAsString();
vars.put("ReadResponse",id);
if(id.contains("STRING TO FIND") == true)
{
vars.put("s_check", "true");
}
else
{
vars.put("s_check", "false");
}
JSR223 PostProcessor 2
String id=prev.getResponseDataAsString();
vars.put("ReadResponse",id);
if(id.contains("STRING TO FIND") == true)
{
vars.put("s_check_1", "true");
}
else
{
vars.put("s_check_1", "false");
}
JSR223 Sampler
SampleResult.setIgnore();
import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;
import org.apache.jmeter.samplers.SampleResult;
//Final Response Assertion
String s1 = "N";
String s2 = "N";
if( ${__isVarDefined(s_check)} == true )
{
s1 = vars.get("s_check");
}
if( ${__isVarDefined(s_check_1)} == true )
{
s2 = vars.get("s_check_1");
}
if( (s1 == "false" && s2 == "false") || (s1 == "false" && s2 == "N") || (s1 == "N" && s2 == "false") )
{
SampleResult.setSuccessful(false); //NOT WORKING
SampleResult.setResponseMessage("accountID page is not loaded"); //NOT WORKING
ctx.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THREAD); //WORKING
}
