0
votes

what is the recommended approach for developing a script in Jmeter from below options if I need to extract single/multiple values from response and Mark sampler as fail if it has error Option 1. Use Jmeter built-in postprocessor for each of the variable needed or grab all variable in one go using regular expression extractor or Json path extractor etc and use assertion to check for the success or failure

Option 2: Use JSR223postprocessor and use groovy to parse response and grab required variable/variables and write code to check the success or failure instead of using built-in assertion

1

1 Answers

0
votes

It is not possible to provide a valid answer without knowing the full details of your requirements, however here are several factors which can help you to take the right decision:

  1. Readability/maintainability of your script. Sometimes it's better to sacrifice minimal performance improvement in order to make your script better understandable by others. So it depends whether your colleagues better understand 2 lines of Groovy code or 20 Regular Expression Extractors or vice versa
  2. Performance. Each PostProcessor has its cost and depending on the number/nature of PostProcessors this or that option may act faster and/or consume less resources. The only way of checking this is measuring the throughput of both solutions using fake data provided by e.g. Dummy Sampler and the solution which has more throughput or consumes less CPU/RAM (whatever is the most important to you) will be the right choice
  3. With regards to Assertions, as per 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure article:

    Every test element added to the test plan will be processed - and this takes CPU time and memory. This also applies to all your Assertions, and is especially true for Compare Assertions - which consumes a lot of resources and memory. Only use the assertions you need and, even then, just use the amount that are absolutely required.