Ask a Question

How to get TestStep Status as Passed/Failed using groovy

SOLVED
ashkht
Contributor

How to get TestStep Status as Passed/Failed using groovy

Hello,

 

I am trying out a way which can give me TestStep Status as Failed/Passed using groovy so that based on this status i can update Pass/fail against test case in excel from where it is data driven.

 

I have one assertion step for both positive and negative validations, which in turn consist multiple assertions, I wanted to get TestStep Status for corresponding assertion step, which will help me to decide what should be written in excel either Pass/Fail.

 

In one of community post, i got clue to use tear down script but i am not aware how it has to be run and how result from this tear down script can be implemented to decide status to be written as Pass/Fail in excel.


https://community.smartbear.com/t5/SoapUI-Pro/Get-all-test-step-result-of-a-test-case/td-p/27746

 

Solution Provided as : 

for( r in testRunner.results )
log.info "TestStep [" + r.testStep.name + "] finished with status " + r.status

 

Can you please assist me on the same.

Thanks,

Ashish 

6 REPLIES 6
Nastya_Khovrina
SmartBear Alumni (Retired)

Hi Ashkht,

 

Thank you for your post. When the test item run finishes, the test engine runs its TearDown script: https://support.smartbear.com/readyapi/docs/soapui/scripts.html

 

To write to Excel file you can use the DataSink test step:

https://support.smartbear.com/readyapi/docs/soapui/steps/data-sink.html

 

BTW, why do you need the test step status, when you can get the status of the whole TestCase: 

for ( testCaseResult in runner.results )
{
testCaseName = testCaseResult.getTestCase().name
testCaseResult.getStatus().toString() }

 


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

Hello Anastasia,

Thanks for your response!

 

Can we write above mentioned script in "Groovy Script" step at the end of test case before "DataSource Loop" step, instead of being written as Tear Down Script.

 

I am interested to get status of TestStep , ex: Assertion step, because i am looping my SOAP UI test case using DataSource Loop test step which will loop in multiple rows of excel, wherein each row corresponds to unique test condition, so that before end of loop/ moving to next test condition, i can get "Assertion" test step status and make a decision whether i should write as "Pass/Fail" for corresponding test case in same excel which is already been used as DataSource instead of using separate DataSink Test Step.

 

Can you please assist with this updated info. PFA snippet of test steps for test case designed in SOAP UI.

Thanks,

Nastya_Khovrina
SmartBear Alumni (Retired)

You can get the status of individual assertions from the Assertion Test Step with the following script in the Groovy Test Step:

def testStep = testRunner.testCase.getTestStepByName("Assertion") //change to your name
def list = testStep.getAssertionEntryList()
 
for( assertion in list)
{
  //log.info(assertion.getProperties())
  log.info("Assertion: " + assertion)
  log.info("Assertion: " + assertion.status)
}

 


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

Hello Anastasia,

Thanks for your response! It was helpful and was able to get TestStep status.

Next, I am trying to write status as "Pass/Fail" to same excel file (which is been used for "Data Source" test step) based on "Assertion" test step status. I have Test data file in location : D:\Test Scripts\TestCases_V3.xlsx and worksheet name as - "140" have a column "Test Results" and have to start writing status at cell X3. As it is data driven, i am trying to write test status to start at this cell, as different test conditions are been executed through "Data Source Loop" test step.

 

Since i am "Intermediate" level in groovy scripting, need some help on how to achieve following parts to complete my reporting part for SOAP UI automation:

1. Able to access test data sheet at X3 cell, wherein i am interested to start writing Test status as "Pass/Fail."
2. To retrive no . of rows count from work sheet - "140", which will act as counter increment.
3. Finally writing test status as "Pass/Fail" as we move on testing different test conditions using - "Data Source/Data Source Loop" test steps.

 

All of above mentioned parts, i am trying to place with help of script in "Groovy" test step before "Data Source Loop" test step. PFA snippet of test step design i have done in SOAP UI test case.

 

Please assist me on the same.

Thanks,
Ashish

Hello All,

 

Appreciate your help on issue which i have mentioned, at last of this message trail.

 

Regards,

Ashish

Nastya_Khovrina
SmartBear Alumni (Retired)

Hi Ashish,

 

I recommend that you open a new support case here: https://support.smartbear.com/message/?prod=ReadyAPI and provide us with your project, so we can easily determine what is done and what should be implemented.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: