Solved
Forum Discussion
SanK
5 years agoOccasional Contributor
Any "ReferenceNumber" value should not be in common across both the JSON files.
In the attached JSON files, I have property "ReferenceNumber" value in JSON1 node1 same as JSON2 node0, that needs to be flagged. Does not matter if other properties have duplicate values, but ReferenceNumber should not be duplicate at all across the JSON1 and also in JSON2.
Regards
nmrao
5 years agoCommunity Hero
Here is the Groovy Script
- Add a groovy script after the second test request step
- Provide correct values step1, and step2
//Update the Request step names below
def step1 = 'Name of the Request step1'
def step2 = 'Name of the Request step2'
//Closure to get the ReferenceNumber from a json of the Given test step
def refNumbers = { step -> new groovy.json.JsonSlurper().parseText(context.testCase.testSteps[step].getPropertyValue('response')).ReferenceNumber }
def list1 = refNumbers(step1)
def list2 = refNumbers(step2)
log.info "Reference Numbers for ${step1} are => ${list1}"
log.info "Reference Numbers for ${step2} are => ${list2}"
assert list1.every { !list2.contains(it) }, 'Does not match the expected result'
-
- nmrao5 years agoCommunity HeroGlad to know you could proceed.
- nmrao5 years agoCommunity HeroHave you run those Request 1, Request 2 steps before running Groovy script test step?
- nmrao5 years agoCommunity HeroI have edited the script in the previous message. Please take the script again.
Change
testSteps['SOAP Request]
to
testSteps[step]