2016-11-02 7 views
-1

enter image description here groovyスクリプトを使ってsoapテストケースの応答から別のsoapテストステップにプロパティの値を転送する方法はありますか?あなたが応答が受信されているのと同じ要求ステップのためのScript Assertionを使用することができ、応答構造groovyを使ってsoapuiのプロパティー転送

<NS1:Envelope xmlns:NS1="http://schemas.xmlsoap.org/soap/envelope/"> 
 
    <NS1:Body> 
 
    <NS2:processRequestResponse xmlns:NS2="http://bussinessfacade.fawryswitch.ebpp.fawryis.com/"> 
 
    <return> 
 
     <Response> 
 
      <SignonRs> 
 
       <ClientDt>2016-04-19T16:58:12.141</ClientDt> 
 
       <CustLangPref>ar-eg</CustLangPref> 
 
       <ServerDt>2016-11-02T13:58:09</ServerDt> 
 
       <Language>en-gb</Language> 
 
       <SignonProfile> 
 
       <Sender>FAWRY</Sender> 
 
       <Receiver>FAWRYRTL</Receiver> 
 
       <MsgCode>BillInqRs</MsgCode> 
 
       <Version>V1.0</Version> 
 
       </SignonProfile> 
 
      </SignonRs> 
 
      <PresSvcRs> 
 
       <RqUID>0045d98c-e81c-43fd-b887-b0b1a1b1641d</RqUID> 
 
       <AsyncRqUID>1a50b367-4aca-4d90-9f95-ddca99e8639d</AsyncRqUID> 
 
       <MsgRqHdr> 
 
       <NetworkTrnInfo> 
 
        <OriginatorCode>FAWRYRTL</OriginatorCode> 
 
        <TerminalId>11427</TerminalId> 
 
       </NetworkTrnInfo> 
 
       </MsgRqHdr> 
 
       <Status> 
 
       <StatusCode>200</StatusCode> 
 
       <Severity>Info</Severity> 
 
       <StatusDesc>Success.</StatusDesc> 
 
       </Status> 
 
       <BillInqRs> 
 
       <DeliveryMethod>POS</DeliveryMethod> 
 
       <BillRec> 
 
        <BillingAcct>0120000200</BillingAcct> 
 
        <BillTypeCode>111</BillTypeCode> 
 
        <BillRefNumber>2feeccae-8fd2-4d41-903a-df2ef96d5264</BillRefNumber> 
 
        <BillInfo> 
 
         <BillSummAmt> 
 
          <BillSummAmtCode>TotalAmtDue</BillSummAmtCode> 
 
          <CurAmt> 
 
          <Amt>370</Amt> 
 
          <CurCode>EGP</CurCode> 
 
          </CurAmt> 
 
         </BillSummAmt> 
 
         <IssueDt>2016-08-01</IssueDt> 
 
        </BillInfo> 
 
       </BillRec> 
 
       </BillInqRs> 
 
      </PresSvcRs> 
 
     </Response> 
 
    </return> 
 
    </NS2:processRequestResponse> 
 
    </NS1:Body> 
 
</NS1:Envelope>

ack.imgur.com/Z7UwT.png

+0

詳細を質問できますか?すなわち、プロパティはどこですか?どのようにそれらを使用したいですか? – Rao

+0

プロパティはsoap test step responseに存在し、実際のプロパティはAmt、AsyncRqUID&BillRefNumberです(レスポンスから量をとり、それを他のすべてのステップに追加する) –

+0

レスポンスのサンプル構造生の反応はどうですか?検索された値は他のテストステップ要求で使用されますが、そうですか? – Rao

答えて

2

を見つけてください。個別のGroovy Scriptステップを使用して回避することができます。したがって、プロパティーとして保存する前に、応答から必要な値をチェックしてください。

スクリプトアサーション:

/** 
* This is script assertion 
* retrieves specified values from currest step response 
* and stores at test case level 
**/ 

//Closure to search the data 
def searchData = { data, item -> 
    data?.'**'.find { it.name() == item} as String 
} 
//Assert the response. 
assert context.response, "Response is empty or null" 

def parsedData = new XmlSlurper().parseText(context.response) 

//Get Amount 
def amt = searchData(parsedData, 'Amt') 
log.info "Amount from response: ${amt}" 
//Check the value amt 
assert amt, "Amount is empty or not present" 
//Store Amount at test case level 
context.testCase.setPropertyValue('AMOUNT', amt) 


//Get AsyncRqUID 
def rqUid = searchData(parsedData, 'AsyncRqUID') 
log.info "AsyncRqUID from response: ${rqUid}" 
//Check the value rqUid 
assert rqUid, "AsyncRqUID is empty or not present" 
//Store RqUid at test case level 
context.testCase.setPropertyValue('AsyncRqUID', rqUid) 

が上記の値をAsyncRqUIDとして量として3701a50b367-4aca-4d90-9f95-ddca99e8639dをフェッチすることになります。下記の通り、あなたがそれらの取得した値を必要とする他のテスト要求工程において

は、使用してください:

  • 金額(AMT)、${#TestCase#AMOUNT}について。例<amount>${#TestCase#AMOUNT}</amount>
  • RqUIDについては、${#TestCase#AsyncRqUID}です。例<rquid>${#TestCase#AsyncRqUID}</rquid>
+0

問題はすべてのテストケースがAMOUNT&AsyncRqUIDであるため、テストスイートレベルを使用できません –

+0

コメントごとに更新された回答があるので、答えを再確認してください。 – Rao

+0

@ラオ感謝alot :) uは私の一日を作った –

関連する問題