Due to the project, SOME time ago, I studied and used the API of SoapUI test tool for self-test development. The following will be the results of the study to show you, I hope to help people in need.

 

What is SoapUI?

SoapUI is an open source testing tool that uses SOAP/HTTP to examine, invoke, and implement functionality/load/conformance tests for Web services. The tool can be used either as a standalone test software or as a plug-in integrated into Eclipse, Maven2.x, Netbeans, and Intellij.

 

The installation of the SoapUI

You are advised to download the latest version of the SoapUI installation package because SoapUI is a Java-based test tool. Installation packages before 3.0 do not integrate JRE, so you have to install and configure the Java runtime environment yourself.

 

The use of SoapUI

1. In the File menu of the main interface, click “New REST Project” and fill in the URL you want to test according to the URL of our Project Teacher Site: Teacher-test.grapecityDev.com:

 

Enter the /Login/Login route in the Resource text box as shown in the following figure, and enter the query parameters accountName and password for Login in the Params.

2. Click the green button to send a login request. The result is displayed in the right pane.

According to the business requirements of the Teacher Site project, after sending the Login request, the SchoolItemChange interface must be sent to return the Token authenticated by the user after successful Login. The value of set-cookie in the following figure will be used in the Cookie attribute of the next GetOverview request header:

“GetOverview” = “GetOverview”; “GetOverview” = “GetOverview”; “GetOverview” = “GetOverview”;

Automated testing

In fact, the invocation of the above three interfaces is just a simple test whether the invocation of the interface is normal. If you want to automate the invocation of the three interfaces, please see the following decomposition:

1. Right-click the Request Request from each interface, as shown in the figure, and select “Add TestCase” to set TestCase for each interface. In TestSteps, Login, SchoolItemChange, GetOverview Three TestCases.

2. Do you notice that there is a Set Cookie under Test Steps?

This is done using Groovy Script syntax to retrieve the return value of the previous request (in this case, the return value of the SchoolItemChange interface “set-cookie”). The “set-cookie” attribute is assigned to the request header Cookie of the next request GetOverview. ! This is a good way to automate interface testing without copying and pasting dependent return values between requests.

3. Add an Assertion for the interface you are testing. Click in the lower left corner of the Add Assertion dialog box.

 

Contains Assertion Indicates that the string returned by the request Contains the specified string. This assertion applies to comparisons of up to 65535 characters, because Soapui is written in the Java language, which is the maximum number of characters supported by the JVM:

Script Assertion Compare GetOverview 01. TXT with HtmlOfPartialView in the request return. Judge whether the two contents are equal:

5. Double-click the Test Case, the picture below will appear. Click the button, or right-click Login and choose “Run from here”, then perform the Test Steps in sequence, as shown in the picture, and the words “Failed” with red background will appear. The response time of the Step 4 GetOverview interface request is 1272ms larger than 500ms set in the assertion:

 

Email sending function

When you want the result of an interface request to be emailed to you, right-click Test Steps -> Add Step -> Groovy Script and Add the Send Email Script, as shown below. Username and Password are the account and Password of the company mail server respectively, and Internet Address is the email Address of the recipient.

${teacher-test#TestCase#Getoverview#Response

Test Suite name # Test Case name # Test Step name # Response

 

Pressure test

So functional Tests, stress Tests, right click Load Tests to create test cases,

Limit: 60 is the time of the pressure Test. Thread indicates that five threads can be run at the same time. Test Delay * Radom indicates the time of random Delay.

Min represents the minimum response time, Max represents the maximum response time, AVG represents the average response time, LAST represents the response time of the last request, CNT represents the number of requests, TPS represents the number of requests processed per second, BPS represents the throughput rate, and RAT represents the error rate.

Right-click to add assertions to the request, Max Errors to set the maximum number of Errors, Step Average to set the expected Average time, and so on:

Load and performance tests for different strategies can be selected as shown below:

The most commonly used policy is Simple, if you want to run a functional test and want to delay 5 Threads in 10 seconds, then the Threads set is 5 with a latency of 1000s and a random latency ratio of 0.5 (which would result in a delay of 5 to 10 seconds).

Variance, Threads refers to the number of Threads with Variance, and Interval sets the desired value for the Interval. For example, if you set 20 threads, 60 intervals and 0.8 variance, the number of threads will increase from 20 to 36 in the first 15 seconds, then decrease to 20 again after 45 seconds, then continue to decrease to 4 threads, and finally return to the initial value of 20 at 60 seconds. It is easy to follow this variance in a statistical graph:

Linear strategies (threads), the number of threads to run from one Thread to another. Its main function is to determine the level at which certain statistical changes or events occur, such as setting start and end thread values (e.g. 1-10), and setting the duration (in this case at least 30 seconds per thread) to get accurate measurements:

 

Continuous integration

For continuous integration in UI interface: right-click Project name REST Project 1 -> Select Launch TestRunner, the following picture appears, select TestRunner installation path in Basic Tab page:

On the Reports Tab, select the Report Output folder:

Click the Launch button to automatically execute the test project.

 

For continuous integration, open the Command Prompt dialog box as an administrator and run the following Command:

testrunner.bat -s'teacher-test' -cLogin -r -j -f'D:\Trivals\SoapUI\Logs' D:\Trivals\SoapUI\REST-Project-1-project.xmlCopy the code

The meanings of the parameters in the command line are as follows:

  • s : The TestSuite to run, used to narrow down the tests to run
  • c : The TestCase to run, used to narrow down the tests to run
  • r : Turns on printing of a small summary report (see below)
  • j : Turns on exporting of JUnit-compatible reports, see below
  • f : Specifies the root folder to which test results should be exported

For more information on SoapUI parameters, please refer to the SoapUI website.

www.soapui.org/test-automa…

This article provides an overview of how to use SoapUI. You are welcome to comment on SoapUI for more information.

Reproduced please indicate from: Grape city control

 

Related reading:

The Web front end implements an Excel – like spreadsheet

Third party control Studio for ASP.NET MVC4 tool application

Create the application using the Wijmo MVC 5 template in 1 minute

 



This article is published by grape city control technology development team, reprint please indicate source: Grape city control

For more development tools and tips, please go to the official website of grape City controls

To learn about enterprise reporting and Web applications, visit the Grape City Enterprise Software website