2017-08-23 4 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が合格または不合格れる見てみたかったです。それが失敗した場合は、First Failedが発生した場所(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

関連する問題