Forum Discussion
The easiest place to put it might be as a groovy script assertion on whichever test step comes last to check. Are you using a test case like this?
- REST Request 1
- JDBC Request 1
- Check results of request-1 here.
- REST Request 2
- JDBC Request 2
- Check results of request-2 here.
- etc.
If that's the case, if you can put a groovy script assertion on whichever step comes last, that would be ideal. Or, if you can provide a screenshot of your test case/steps as they exist now, that might give us a better idea of what you want. Mock it up with sample steps if needed, but how do you envision it working?
As far as I know, you'll have to re-use this groovy script every time you want to check a set of two test steps with each other. Either as a script assertion or as a groovy script test step.
- US_206 years agoOccasional Contributor
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.
- US_206 years agoOccasional Contributor
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
- US_206 years agoOccasional Contributor
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.
Related Content
- 2 years ago
- 4 years ago
- 5 years ago
- 5 years ago
Recent Discussions
- 17 seconds ago
- 2 minutes ago
- 2 hours ago