-1

Scenario is: 1000 users signup at same time.

Now, if the response message in "View results in a Tree" is "1", its successful registration, But if response message "3", its failed request.

I would like to know how can I handle this in Beanshell Post processor.

OR

Is it possible to have csv with result of all registration?

Anonymous
  • 858
  • 4
  • 27
  • 54

3 Answers3

2

Something like:

String response = new String(data);

if (response.equals("3")) {
    prev.setSuccessful(false);
}

Where:

  • data - is an array of Java bytes holding parent sampler response
  • prev - is an instance of SampleResult class providing read/write access to parent sampler methods and fields

More information - How to Use BeanShell: JMeter's Favorite Built-in Component


NB: It will be much faster and easier to go for Response Assertion instead of the Beanshell PostProcessor

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
0

When you say response, what do you mean.

You can do it like this:

  • add a response assertion and use contains, fill in a regexp for the place where the code "1" is. In all other cases you will have failure

Another way to do it:

  • use a regexp extractor to extract response "code"
  • use a jsr223 assertion + groovy, and test the variable extracted value
UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
0

Well, why do you need a beanshell for this? You can extract the "response bits" you want to validate using a regexp and use an if controller by comparing the response bits with expected values using the deafult javascript option. In the following example, I am extracting a word from the previous response and taking a decision using if controllerenter image description here

Kranthi Paidi
  • 301
  • 1
  • 4