1

How i can compare two dataset return from diffrent operation in Jmeter ? First data returns from JDBC PreProcessor - Declear variable StCode and data returns in below mention format StCode_1 = abc StCode_2 = ad StCode_3 = abcd StCode_4 = adw StCode_5 = abcq StCode_6 = adr

Second data returns from JSON Extractor - Declear variable StCodeJson and data returns in below mention format StCodeJson_1 = abc StCodeJson_2 = ad StCodeJson_3 = abcd StCodeJson_4 adw StCodeJson_5 = abcq StCodeJson_6 = adr

I want to compare StCode and StCodeJson, Can we store both data in string or list? Or how we can proceed with other ways ?How i can compare two dataset return from diffrent operation in Jmeter ? First data returns from JDBC PreProcessor - Declear variable StCode and data returns in below mention format StCode_1 = abc StCode_2 = ad StCode_3 = abcd StCode_4 = adw StCode_5 = abcq StCode_6 = adr

Second data returns from JSON Extractor - Declear variable StCodeJson and data returns in below mention format StCodeJson_1 = abc StCodeJson_2 = ad StCodeJson_3 = abcd StCodeJson_4 adw StCodeJson_5 = abcq StCodeJson_6 = adr

I want to compare StCode and StCodeJson, Can we store both data in string or list? Or how we can proceed with other ways?

1

You can use Response Assertion for this, it can compare 2 JMeter Variables, for example if you want to compare StCode_1 and StCodeJson_1 variables:

  1. Add Response Assertion as a child of the request which you want to fail if the comparison fails
  2. Configure it as follows:

    • Apply to: JMeter Variable - > StCode_1
    • Pattern Matching Rules: Equals
    • Patterns to Test: ${StCodeJson_1}

      JMeter Response Assertion

  3. If there will be a mismatch - JMeter will fail the parent Sampler and report the reason as an Assertion Failure message:

    JMeter Compare Variables

You can also use JSR223 Assertion to compare all the variables in one shot using some form of For Loop.

Check out How to Use JMeter Assertions in Three Easy Steps article for more details on conditionally failing JMeter samplers using Assertions.

  • I have to comapre entire data set. – Akhilesh Nuwal Sep 25 '17 at 12:21
  • Then in JSR223 Assertion use the code like: for(inti=1;i<=Integer.parseInt(vars.get('StCodeJson_matchNr'));i++){if(!vars.get('StCodeJson_'+i).equals(vars.get('StCode_'+i))){AssertionResult.setFailure(true)AssertionResult.setFailureMessage('Variables mismatch')}}. See Apache Groovy - Why and How You Should Use It to learn more about Groovy scripting in JMeter tests. – Dmitri T Sep 25 '17 at 12:48
  • Can we store both dataset in array or list > – Akhilesh Nuwal Sep 26 '17 at 6:21
  • Thanks for reply!! I used this code, getting below mention error - Assertion failure message: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: i for class: Script4 – Akhilesh Nuwal Sep 26 '17 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.