Forum Discussion
Hi,
Thanks again. Below is a sample of my test case.
Test case name
Sku
soapreq1
soapreq2
Restreq1--returns the morphonly amt ( can be a +ve value or -ve value)
soapre3--- where the Order total value in the groovy script is asserted
RestReq2
JDBCreq1
JDBCreq2
Groovy script
Datasink
Datasourceloop
Groovy script:
Get the morphonly amount from restreq1
def morphOnlyrestResponse = getdata
//Get the total amount from soapre1
def searchOrdersoapresponse = getdata
def ordertotal = new JsonSlurper().parseText(searchOrdersoapresponse);
log.info("ordertotal = "+ordertotal);
def morphonly = new JsonSlurper().parseText(morphOnlyrestResponse);
log.info("morphonly = "+morphonly);
if (ordertotal > 0)
{
assert (ordertotal == morphonly)
log.info("Assertion positive Pass");
}
Questions:
So I want to make sure the above groovy script runs for every row in the Sku(data sheet). And my assumtion is if the order total is 0, then the groovy script will still execute as a test step?
I tried including def tc = testRunner.testCase.testSteps in my groovy script in the beginning. But when the order total was 0. i checkeed in the trasaction log, TestStepResult: Step[Groovy script] ran with assertion status [PASS]. Not sure if this is a correct way of doing it? Please advice.
Can anyone please help?
- richie6 years agoCommunity HeroHi,
I might be misunderstanding the problem here, but is it not what either groovyguy or nmrao said in a previous post? I.e. add the groovy as a script assertion on the relevant test step?
So if you sku datasource is pointing to a spreadsheet and you want the groovy to execute for each row, essentially each row of the datasheet equates to the rest or soap step that sources the data from the spreadsheet. Just add the groovy and tailor it if necessary so it works as a script assertion on that particular rest or soap step?
Or have i misunderstood?
Cheers,
Richie
Related Content
- 2 years ago
- 4 years ago
- 2 years ago
- 7 years ago
Recent Discussions
- 2 hours ago
- 2 hours ago
- 2 hours ago
- 3 hours ago