Sunday, November 24, 2013

Data Binding in Web Test (Web Service Test)

Today I would like to share how to perform parametrized functional test on WCF web service by using Visual Studio 2012.

Note: Only for Visual Studio Test Professional or Ultimate Edition.

First, create a new Web Performance and Load Test Project.


Then, add a new web service request in your web test.


Open up the properties window for the newly created web service request. Enter your WCF service URL in the Url property.



Add a new HTTP header for your web service request. 



Open the properties window for your newly added header. Select the name as SOAPAction.


Then enter the value for the SOAP action. The value is depending on which service operation that you would like to test. The information can be obtained from WSDL.



Open the properties window for String Body. Select the content type as text/xml. Then, enter the SOAP message into the String Body property. If you do not know how to form a proper SOAP message, here is a shortcut tip for you.



Open up WCF Test Client. It is located at C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\wcftestclient.exe. Or, you can fire up Developer Command Prompt for VS2012 from your all programs list, then enter wcftestclient in the command prompt.



At the My Service Projects, right click it then select Add Service. Enter your WCF service Url, then hit the OK button.

Double click the service operation that you want to test. Fill in all the required values. Then hit the Invoke button.



Click the XML tab at the bottom of the window.



Copy the XML from the Request field. That is the SOAP message that you need to put into the String Body in the web test in Visual Studio.



Go back to Visual Studio, paste the copied XML from the WCF Test Client into the String Body property field. Remove the whole <Action> element from the SOAP Header if the WCF service endpoint is configured with basicHttpBinding which is using SOAP version 1.1.



Hit the OK button, then click the Run Test button to test whether the SOAP message is accepted by the WCF service. You should expect the return is HTTP200 status and expected SOAP message response.


Now, prepare test data for parametrization. Open Microsoft Excel or Notepad to create a comma delimited text file (*.csv). The first row always is the column name, the subsequent rows are the test data.



Go back to Visual Studio, right click the Data Sources folder, click Add Data Source. Enter a data source name, select CSV file, then click Next button. Click the Browse button and choose the CSV file which you had just created with test data.



Open up the String Body property field editor. Replace the value that you want to parametrize with {{DataSourceName.TableName.ColumnName}}.



Open up the Local.testings from the Solution Explorer.



Go to Web Test, choose the radio button "One run per data source row". Click the Apply button, then close the window.



In the web test window, click the Run Test button. You should expect to see multiple run with different request SOAP message.









1 comment:

Send Transactional SMS with API

This post cover how to send transactional SMS using the Alibaba Cloud Short Message Service API. Transactional SMS usually come with One Tim...