Hi All, I am fairly new to Jmeter. I need some help with the following:
I have test which runs 8 different webservices one after the other. I am exctracting values from each response using regular expressions (i.e STATUSCODE1,STATUSCODE2,etc.. STATUS CODE8). I would like to save all these values into a single txt file saying test is pass at the end of the test run. If anything fails i would like to see a message as test fail. Can any one help me? Sofar, i have tried Bean shell scripting, but my code only saves one status code not all.
f = new FileOutputStream("C:\\FinalTestResults.txt");
p = new PrintStream(f);
Your intent of using Beanshell is a good approach. I would recommend however not to reinvent the wheel and use BeanShell Post Processor instead of sampler.
Beanshell Post Processor provides pre-defined variable called prev which stands for SampleResult class instance (another way of retrieving this is
SampleResult class provides following methods which can be useful to you, to wit:
isSuccessful() - boolean, true if request is successful, elsewise is false.
getResponseCode() - String.
getResponseMessage() - String
getResponseData() - byte Can be cast to String as new String(byte)