2017-08-23 33 views
0

我有以下結構:如何識別步驟是在SoapUI中的RunTestCase?

每個單一功能在可重用腳本中被分解並在主套件中重用所有功能。

TestCase 1: 
    1. Login as Normal Customer (This is calling login test case from Reusable script) 
    2. Extract Session from STEP 1 
    3. Add diner card (This is calling add card test case from Reusable script) 
    4. View Added Card (This is calling view test case from Reusable script) 
    5. etc.. 

現在每個測試用例可重複使用的腳本返回r_result(已通過或失敗)

現在我想檢查每次運行測試案例,看看屬性r_result傳遞或失敗的屬性。如果失敗,我需要檢查第一次失敗發生的位置(在RunTestCase)並報告錯誤。

是否有可能分離每個測試用例中的RunTestCase步驟,並在閉包中使用它來獲取每個RunTestCase結果的結果?

+0

是要找到整個測試套件的測試案例「RunTestCase」式的測試步驟? – Rao

回答

1

以下是可以在soapui項目中獲取匹配測試步驟列表的腳本。

請按照在線評論。

result變量具有所需類型的測試步驟的所有列表。您可以利用這些數據並做必要的工作。

腳本:

import com.eviware.soapui.impl.wsdl.teststeps.WsdlRunTestCaseTestStep 

//To identify lookup test step is not this step 
def currentStepMap = [ suite : context.testCase.testSuite.name, case : context.testCase.name, step : context.currentStep.name ] 
//Type of step to look for 
def stepTypes = [WsdlRunTestCaseTestStep] 
//To hold the final result 
def result = [] 

//Find the test step details of matching step 
def getMatchingMap = { suite, kase, step -> 
    def tempMap = [suite : suite.name, case : kase.name, step: step.name] 
    def isNotMatching = currentStepMap != tempMap ? true : false 
    if (isNotMatching &&(stepTypes.any{step in it})) { 
     tempMap 
    } else { [:] } 
} 

def project = context.testCase.testSuite.project 

//Loop thru the project and find the matching maps and list them 
project.testSuiteList.each { suite -> 
    suite.testCaseList.each { kase -> 
     kase.testStepList.each { step -> 
      def tempResult = getMatchingMap(suite, kase, step) 
      if (tempResult) { 
       result << tempResult  
      } 
     } 
    } 
} 

if (result) { 
    log.info "Matching details: ${result} " 
} else { 
    log.info "No matching steps" 
} 
+0

謝謝你。按預期工作...... – ChanGan

+0

@ChanGan,很高興知道它有幫助。 – Rao

相關問題