soapui test suite to robot framework test suite code example

Example: soapui test suite to robot framework test suite

*** Variables ***
${SoapUI_suite}=     TestSuite
${SoapUI_Project}=   Project_File
${test_runner}=   /home/pprz/SoapUI-5.4.0/bin/testrunner.sh
${output_path}=  /tmp

*** Keywords ***
SoapUI Test Runner ${Test_Case}
   ${cmd_out}=  Run  unset DISPLAY && ${test_runner} -s ${SoapUI_suite} -c ${Test_Case} -rMI -f ${output_path} ${SoapUI_Project} | tail -10
   Log  ${Test_Case} Test Case Results Summary: ${cmd_out}  WARN
   Should Contain  ${cmd_out}  SoapUI 5.4.0 TestCaseRunner Summary
   File Should Exist  ${output_path}/test_case_run_log_report.xml

Process XML results ${Test_Case}
   ${xml_out}=  Get File   ${output_path}/test_case_run_log_report.xml
   ${root}=  Parse XML  ${xml_out}
   Element Attribute Should Be  ${root}  testCase  ${Test_Case}
   ${result}=  Get Element Attribute  ${root}  status
   Run Keyword If  '${result}' == 'FINISHED'  Log  Test Case: ${Test_Case} Passed, Result: ${result}   WARN
   Run Keyword If  '${result}' != 'FINISHED'   Report Failed Case ${Test_Case}

Report Failed Case ${Test_Case}
   ${xml_out}=  Get File   ${output_path}/test_case_run_log_report.xml
   ${root}=  Parse XML  ${xml_out}
   @{test_steps}=  Get Elements  ${root}  testCaseRunLogTestStep
   :FOR  ${step}  IN  @{test_steps}
   \  ${step_status}=  Get Element Attribute  ${step}  status
   \  ${step_name}=  Get Element Attribute  ${step}  name
   \  ${failed_steps}=  Set Variable If  '${step_status}' != 'OK'  ${failed_steps}, "${step_name}"
   \  ${timeTaken}=  Get Element Attribute  ${step}  timeTaken
   \  Log  Step: ${step_name} , Time Taken: ${timeTaken}, Status: ${step_status}  WARN
   \  Run Keyword If  '${step_status}' != 'OK'   Get Message ${step_name}
   Fail  \nTest Case ${Test_Case} Failed in following steps: ${failed_steps}

Get Message ${step_name}
   ${xml_out}=  Get File   ${output_path}/test_case_run_log_report.xml
   ${root}=  Parse XML  ${xml_out}
   ${failed_step}=  Get Element  ${root}  testCaseRunLogTestStep[@name="${step_name}"]
   @{failed_messages}=  Get Elements Texts  ${failed_step}  message
   Log  ${failed_messages}[0]  WARN

TestRunner ${case}
  SoapUI Test Runner ${case}
  Process XML results ${case}

Delete XML Report
  Run  rm -f ${output_path}/test_case_run_log_report.xml &>/dev/null

Tags:

Misc Example