testing web services using soapui

15
Testing web services using SoapUI 1 Testing web services using SoapUI SoapUI を使って Web サービスをテストする) 【目次】 1 Preparation(準備)...................................................................................... 2 2 Publish more microflows as web service operation Web サービス・オペレーションとしてマイクロフローを追加発行する) ................... 2 3 Create a new SOAP projectSOAP プロジェクトを新規作成する)........................ 4 4 Build a TestSuite, a TestCase and a TestStep (テストスイート、テストケース、テストステップをビルドする)............................. 5 5 Assertions(アサーション) ............................................................................ 9 6 Extend your test case(テストケースを拡張する)............................................ 10 7 Run the test case(テストケースを実行する) ................................................. 13 8 Related content(関連するコンテンツ).......................................................... 14 Mendix アプリケーションに独自の Web サービスを公開することができます。これらの Web サービスは、オペレーションで構成されます。他のアプリケーションからこの Web サービスの オペレーションを呼び出し、この Web サービスからの結果を取得することが可能になります。 この結果は、Web サービス呼出し時に実行されるマイクロフローに基づいています。SoapUI を使えば、これらの Web サービスの(自動)テストを作成することが可能です。 この章では、以下の内容を学習します。 SoapUI を使って SOAP プロジェクトを作成する SoapUI でアサーションを作成する SoapUI を使って自動テストをビルドする

Upload: others

Post on 14-Mar-2022

13 views

Category:

Documents


0 download

TRANSCRIPT

Testing web services using SoapUI 1

Testing web services using SoapUI (SoapUI を使って Web サービスをテストする)

【目次】

1 Preparation(準備) ...................................................................................... 2

2 Publish more microflows as web service operation

(Webサービス・オペレーションとしてマイクロフローを追加発行する) ................... 2

3 Create a new SOAP project(SOAPプロジェクトを新規作成する) ........................ 4

4 Build a TestSuite, a TestCase and a TestStep

(テストスイート、テストケース、テストステップをビルドする) ............................. 5

5 Assertions(アサーション) ............................................................................ 9

6 Extend your test case(テストケースを拡張する) ............................................ 10

7 Run the test case(テストケースを実行する) ................................................. 13

8 Related content(関連するコンテンツ) .......................................................... 14

Mendix アプリケーションに独自の Web サービスを公開することができます。これらの Web

サービスは、オペレーションで構成されます。他のアプリケーションからこのWebサービスの

オペレーションを呼び出し、このWebサービスからの結果を取得することが可能になります。

この結果は、Web サービス呼出し時に実行されるマイクロフローに基づいています。SoapUI

を使えば、これらのWebサービスの(自動)テストを作成することが可能です。

この章では、以下の内容を学習します。

SoapUIを使って SOAPプロジェクトを作成する

SoapUIでアサーションを作成する

SoapUIを使って自動テストをビルドする

Testing web services using SoapUI 2

1 Preparation(準備)

この章の学習内容に進む前に、以下の作業を行ってください。

SoapUIをダウンロードおよびインストールする。

Exposing a web serviceの作業を完了する。

ソフトウェア この章で使用されるバージョン

Mendix Business Modeler 5.20.0

SoapUI 5.2.0

この章で使用される画像、名前、および手順は、すべて上記のバージョンに基づいています。

他のバージョンをご利用の場合は、画面に表示される画像や名前がこの章に登場する内容と異

なるかもしれません。

2 Publish more microflows as web service operation

(Web サービス・オペレーションとしてマイクロフローを追加

発行する)

Exposing a web serviceの章で、Webサービス・オペレーションとして_GetCustomers _マイクロ

フローを発行しました。この節では、さらに 2 つのマイクロフローを作成し、それらを Web サービス・オ

ペレーションとして公開します。

1. Mendix Business Modelerを開きます。

2. Exposing a web serviceの章で作成したプロジェクトを開きます。

3. Customerを作成し、ブール値を戻すマイクロフローを作成します。

Testing web services using SoapUI 3

4. Customerを削除し、ブール値を戻すマイクロフローを作成します。

5. Exposing a web service の節 4 に記載されているとおり、両マイクロフローを

CustomerWebserviceのWebサービス・オペレーションとして発行します。

Testing web services using SoapUI 4

3 Create a new SOAP project

(SOAP プロジェクトを新規作成する)

この節では、SOAPプロジェクトを新規作成します。

1. SoapUIを開きます。

2. CTRL+Nを押し、SOAPプロジェクトを新規作成します。

3. Mendix Business Modelerでプロジェクトをローカルで実行します。

4. http://localhost:8080/ws-doc/に移動します。

5. SoapUI の Initial WSDL フィールドに WSDL Schema の URL を入力します。Project

Nameフィールドに、末尾に?wsdl が付いたwebサービス名が自動的に入力されます。

Testing web services using SoapUI 5

6. **OK**をクリックします。SoapUIに SOAPプロジェクトが新規作成されます。

4 Build a TestSuite, a TestCase and a TestStep

(テストスイート、テストケース、テストステップをビルドす

る)

この節では、テストスイートをビルドします。テストスイートには、1 つ以上のテストケース

が含まれます。すべてのテストケースには、1つ以上のテストステップが含まれます。

1. SoapUIで CTRL+Tを押し、TestSuiteを新規作成します。

2. OKをクリックします。

3. TestSuite 1を選択し、CTRL+Nを押して TestCaseを新規作成します。

Testing web services using SoapUI 6

4. OKをクリックします。

5. TestSuite 1と TestCase 1を展開します。

6. Test Steps(0)を右クリックし、SOAP Requestを選択します。

7. Nameフィールドに Retrieve Customersと入力します。

8. OKをクリックします。

9. CustomerWebserviceSoap -> GetCustomersを選択します。

10. OKをクリックします。

Testing web services using SoapUI 7

11. OKをクリックします。

12. Retrieve Customers SOAPリクエストを開きます。

以下の値:

<Offset>?</Offset>

<PageSize>?</PageSize>

を、以下の値:

<Offset>0</Offset>

<PageSize>10</PageSize>

に変更します。

13. ALT+Enter を押し、リクエストをサブミットします。先ほどの章で作成した

Customer がレスポンスに表示されます。レスポンスは以下のようなコードになりま

す。

Testing web services using SoapUI 8

<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="ht

tp://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlso

ap.org/soap/envelope/" xmlns:tns="http://www.example.com/">

<soap:Body>

<tns:GetCustomersResponse>

<Customer>

<Name>Jessica D. Rogers</Name>

<Address>2118 Collins Street</Address>

<ZipCode>PA 16646</ZipCode>

<City>Hastings</City>

</Customer>

<Customer>

<Name>Jamie S. Wentz</Name>

<Address>3269 Village View Drive</Address>

<ZipCode>MD 20872</ZipCode>

<City>Damascus</City>

</Customer>

<Customer>

<Name>Blake G. Race</Name>

<Address>4437 Sunny Glen Lane</Address>

<ZipCode>OH 44115</ZipCode>

<City>Cleveland</City>

</Customer>

<Customer>

<Name>Angela L. Dolly</Name>

<Address>3718 Alpha Avenue</Address>

<ZipCode>TX 75439</ZipCode>

<City>Ector</City>

</Customer>

</tns:GetCustomersResponse>

Testing web services using SoapUI 9

</soap:Body>

</soap:Envelope>

5 Assertions(アサーション)

アサーションは、通常はメッセージの一部(または、メッセージ全体)を一部の期待値と比較す

ることで、テストステップ実行中に受け取ったメッセージを検証するために使われます。この

節では、Customer数を検証するアサーションを作成します。

1. Assertions (1)をクリックします。

節 3の手順 9で、Add SOAP Response Assertion チェックボックスにチェックを入れま

した。これがリスト内の 1つ目のアサーション SOAP Response - VALIDです。

2. Add assertionアイコンをクリックします。

3. Property Contentをクリックします。

4. XPath Matchをクリックします。

5. XPath Expressionフィールドに count(//Customer)と入力します。

6. 先ほどの章の手順 1.4 で、データを少し追加しました。Expected Result フィールドに

Testing web services using SoapUI 10

作成した Customer数を入力します。ここでは、4件の Customerレコードを作成しまし

た。

7. Saveをクリックします。

6 Extend your test case(テストケースを拡張する)

この節では、複数のテストステップやアサーションを使って、テストケースを拡張します。

1. 既存のテストケースに、以下の情報を含めて新規 SOAPリクエストを追加します。

フィールド 値

Specify name for step Create Customer

Select operation to invoke for request CustomerWebServiceSoap ->

CreateCustomer

2. リクエストを以下の値に変更します。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:exam="http://www.example.com/">

<soapenv:Header/>

<soapenv:Body>

Testing web services using SoapUI 11

<exam:CreateCustomer>

<Name>Donald A. Hylton</Name>

<Address>784 Better Street</Address>

<City>Kansas City</City>

<ZipCode>KS 66102</ZipCode>

</exam:CreateCustomer>

</soapenv:Body>

</soapenv:Envelope>

3. Contains Assertionを追加し、Contentフィールドに trueと入力します。

4. Retrieve Customersテストステップを右クリックします。

5. Clone TestStepを選択します。

6. TestStep Nameを Retrieve Customers 2に変更します。

Testing web services using SoapUI 12

7. OKをクリックします。

8. Retrieve Customers 2テストステップを開きます。

9. Assertions (2)をクリックします。

10. XPath Match – Unknownを開きます。

11. Expected resultを 1 + [手順 5.6で入力した数字]に変更します。

12. Saveをクリックします。

13. 以下の詳細を含めて既存のテストケースに新規 SOAPリクエストを追加します。

Specify name for stepに Delete Customerと入力します。

Select operation to invoke for requestフィールドに CustomerWebServiceSoap

-> DeleteCustomerと入力します。

14. リクエストを以下の値に変更します。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope

/" xmlns:exam="http://www.example.com/">

<soapenv:Header/>

<soapenv:Body>

<exam:DeleteCustomer>

<Name>Donald A. Hylton</Name>

</exam:DeleteCustomer>

</soapenv:Body>

</soapenv:Envelope>

Testing web services using SoapUI 13

7 Run the test case(テストケースを実行する)

この節では、先ほどの節で作成したテストケースの実行方法を学習します。

1. TestCase 1テストケースを開きます。

2. Run this testcaseアイコンをクリックします。

Testing web services using SoapUI 14

おめでとうございます!はじめての SoapUIを使った自動テストが出来上がりました。

8 Related content(関連するコンテンツ)

Find the Root Cause of Runtime Errors

Clear Warning Messages

Monitoring Mendix Using JMX

Debug Java Actions Remotely

Log Levels

Debug Java Actions

Handle Common Mendix SSO Errors

Debug Microflows

Debug Microflows Remotely

このトピックの詳細については、次のリンクを参考にしてください。

10 tips for the SoapUI beginner

This Japanese translation is provided for by Buildsystem Co. Ltd., based on Mendix

Testing web services using SoapUI 15

copyrighted documentation and materials which can be found here as licensed under CC

BY 4.0