cancel
Showing results for 
Search instead for 
Did you mean: 

testcase status via groovy

Highlighted
Super Contributor

testcase status via groovy

I have trying to get the status of all test cases after a test suite finishes

testsuite code.

for (i in 0..testSuite.testCaseList.size()-1)
{
def testCase = testSuite.getTestCaseAt(i)
log.info(testCase.getLabel() )
        log.info(testaCase status)

       
}

how can I output the status of the test case here
log.info(testaCase status)
5 REPLIES 5
Highlighted

Hi,

Unfortunately there is no such property as TestCase status.
What you could try is going through each TestStep of a TestCase and check it's assertionStatus if it is assertable. The groovy script could look something like this :


for(testCase in testSuite.testCaseList) {
def failed = false
for(testStep in testCase.testStepList) {
  if( testStep instanceof com.eviware.soapui.model.testsuite.Assertable && testStep.assertionStatus.toString() != "VALID" ) {
  failed = true
  break;
  }
}
if( failed ) log.info testCase.toString() + " FAILURE!"
else log.info testCase.toString() + " SUCCESS!"
}


Regards,

/Dragica
eviware.com


Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted

Hi Ali,

Here 's a new suggestion for you.

1) in the setup script of the TestSuite, put an empty list in the context for holding the different TestCase runners
context.runners = []


2) in the tearDown script of each TestCase, put that TestCases' runner in this list
context.runners.add( testRunner )


3) in the tearDown script of the TestSuite, go through the list of collected runners
for( runner in context.runners )
      log.info runner.status


This solution is far better since it works on all TestStep types regardless if they are assertabe or not.

Regards
/Dragica
eviware.com


Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Super Contributor

If I already have hundreds of testcases, is there an easier way to put the teardown script of each testcase without going to each test case manually.

can this be somehow done at the project load script ?

Also, what is the reason for the API not to be able to expose testcase stautus for tests cases that are in the testsuite.

Thanks

Ali
Highlighted

Hi Ali,

I totally agree that this is awkward, the upcoming version will have better API's for this as you request. If you don't want to modify hundreds of testcases you could instead create a TestRunListener extension (as described at http://www.soapui.org/architecture/extensions.html) that puts the testRunner in the context variable in the afterRun event.

sorry for the hassle.

regards!

/Ole
eviware.com


Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Occasional Visitor

Just a quick one... How would one add the name to the runner.status ?

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors