Introduction to the API Automation test Soap UI Tool

Source: Internet
Author: User
Tags soapui soap ui groovy script

First, Build Test Cases

(i) Basic Concepts

The hierarchical structure of the project in SoapUI

    • Project name : At the top level (bookstoretest), the project can contain definitions for multiple services.
    • Rest Service definition : A service is actually a grouping of multiple REST resources, and in our case there is only one service Bookstoreservie
    • REST Resource Definition : Describes the name, URI, parameters, and other properties of the resource
    • REST Method Definition : Method for each resource (get,post,put,delete, etc.), the method name in Figure 1 is getbooklist
    • REST operation Request Definition : Based on each method, there can be one or more request actions, such as getbooklistrequest, that are actually executed by SoapUI. Each request can have a very rich set of information, such as the type of Accept, the Header information requested, and after the request is run, the results of the operation can be viewed in various ways. However, there is no way to add assertions to validate the results-it must be used after the test case is established.

TestCase definition

    • TestSuite: Similar to the test suite in Junit, where multiple TestCase can be added
    • TestCase: can contain multiple teststep
    • teststep: A TestCase can contain multiple teststep,teststep types, which can be a REST operation request mentioned above, a Groovy script, or an action to set properties. Teststep even supports branch jump operations: Depending on the specific conditions, you can jump from one step to the other step without having to execute it sequentially.

(ii) creation of REST services

1. Create a new project named Resttest

2. Right-click on the project, select "Newrest Service", enter service Name (authenticationservice) and endpoint (http://qa-server11.achievo.com:33080) in the dialog box

3. Right-click on "AuthenticationService", select "New Resource", enter Resource Name (Auth) and Resource Path (/apis/v1/auth/agency) in the dialog box, Click OK

4. In the Pop-up dialog box, enter method Name:signon4agencyuser,http method to select the default POST, click OK

5. Right-click on "Signon4agencyuser", select "Newrequest" and enter "Request login Success" in the dialog box.

Create a REST Services

(iii) creating test Cases

There are two main ways of doing this:

    • Automatically generated with the following steps:
      (1). Right-click a REST service, such as "AuthenticationService" in this example, and select "Generate TestSuite"
      (2). In the dialog box that pops up, leave the default setting and select "OK"
      (3). Enter a name such as "AuthenticationService TestSuite" and select "OK".
    • To create it manually, follow these steps:
      (1). On the project "Resttest", right click, select "New TestSuite", enter "AuthenticationService TestSuite" in the dialog box
      (2). Right-click on AuthenticationService TestSuite, select "New TestCase" and enter "login TestCase" in the dialog box.
      (3). Then in the left navigation bar, expand login TestCase, right-click on "Test Steps" and select Add step->rest test Request
      (4). In the dialog box that pops up, select "Request Login Success"

(iv) adding assertions

After the test case is built, you need to add assertions to the test case to verify the correctness of the results. The SoapUI supports response SLAs, Script assertion, Contains, XQuery match, Schema Compliance,xpath match, and not Contains for various assertions to RESP Onse is judged to ensure high quality testing of WEB services.

Click the TestCase Add Assertions button. Select the XPath Match assertion in the pop-up selectassertion window and click OK. Configure the XPath as shown:

(v) running test Cases

Second, Performance Testing

Performance testing is called Load Test in SoapUI, and for a SoapUI TestCase, you can create one or more LoadTest, which automatically adds all the steps in LoadTest to it, while running, s OAPUI will automatically use multiple threads to run these teststep, while also monitoring their uptime, such as the shortest time, maximum time, average time, and so on. This allows the user to visually see the response time of the rest service to tune performance.

Building LoadTest is very simple, just right-click on "Load Tests", select "Newloadtest", then enter the name, is a performance test for getbooklist, you can see there are two teststep: "Getbooklis T_xml "and" Getbooklist_json ", 100 threads are executed concurrently, with a time limit of 60 seconds. The final result is a minimum of 4 milliseconds, a maximum time of 1204 milliseconds, and an average time of 20.54 milliseconds.

Introduction to the API Automation test Soap UI Tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.