We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
You can use the following code:
...
if (!(it.value == outputResp[it.key]))
{
log.info ("File Mismatch at : " + it.key)
testRunner.fail( "File mismatch..." )
}
...1.Yes. Is that possible?
2. True!
i found some Code and it works but maybe u can help me. If there is a Mismatch there is only a log.info and the test continues with "PASS". Is taht possible to say is there a mismatch the test failed?
import groovy.json.JsonSlurper
def filePath = "C:/qwerty/test.json"
def jsonResp = context.expand('${GET ProCon#Response}')
def outputResp = new JsonSlurper().parseText(jsonResp)
def baselineResp = new JsonSlurper().parseText(new File(filePath).text)
baselineResp.each{
if (!(it.value == outputResp[it.key]))
{
log.info ("File Mismatch at : " + it.key)
}
}You can use the following code:
...
if (!(it.value == outputResp[it.key]))
{
log.info ("File Mismatch at : " + it.key)
testRunner.fail( "File mismatch..." )
}
...Lucian
it works.
and now my next question. i have a [] in my json. Is there a error/mismatch in the [] let me take a example... lets say i have Items[] and in Itmes i have a OID = 123456, Name = XYZ for now the test can say me there is a error/mismatch in ITEMS but not where. It cant say error or mismatch in Items>OID.
jhanzeb1
im complity new to groovy where i need to add "assert i.e assert expected == actual" and did i need to delete anything?