How to know if a groovy step PASSED or FAILED ?
Hi,
I have some test cases with REST and Groovy steps, sometimes the Groovy steps fails (a red star icon). At the end of the test cases, I have a groovy script that creates a report with the passed or failed test. For the REST services it goes well, I can check if the assertions passed or failed with something like: "testStep.getAssertionAt(j).getStatus().toString()". But so far, I can't find a way to check the status of a previously ran Groovy steps. Those test case are made to run at night, and I would like to just have to look at the report in the morning.
Actually, I found a way, which is not very 'nice', with the testStep.getIcon(), if it finishes with 'failed_groovy_step.png' it means that the test failed... But there is surely a better way to know the status of a groovy script ?
Thanks for help.
Jan
Hi Jan,
You should use
testRunner.getResults()
For instance, in a TestCase Teardown script:
Map resultOf = testRunner.getResults() .collectEntries { result -> [ (result.testStep): result.status ] } def mystep = context.getTestCase().getTestStepByName("Some step") log.info resultOf[myStep]
In the attached project is another TestCase Teardown example, and an example of how to get the results from a TestSuite Teardown script.