51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 14392|回复: 12
打印 上一主题 下一主题

[原创] 利用soapui工具对webservice进行性能测试

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2008-2-21 17:10:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
昨天安装了soapui一个可以对webservice作功能和性能测试的东东,感觉比较好用
可以直接很方便的创建测试用例和进行测试,现在在网站上截下个介绍,希望对大家有所帮助
http://www.soapui.org/gettingstarted/sample-project.html

soapUI Sample Project

We know that getting started with a new application always is a challenge. In order to make it easier for you, soapUI comes shipping with a sample soapUI Project file. This soapUI Projects illustrates some of the basic concepts of soapUI and can be used as a soapUI starting point; try out the project, run the included MockService and the included tests in order familiarize yourself with the soapUI interface, and then move on to the Getting Started tutorial.

Here are the main concepts that are illustrated in the soapUI Project.
Web Service Mocking

Web Service Mocking is way to fake the functionality of a Web Service in soapUI; to create a Mock Up. But why do you need such functionality?

Web Service Mocking is very useful in projects where implementation of the Web Service has not started or is not finished for use yet or where you for some other reasons can't access the Web Services live.

In other words, Web Service Mocking makes it possible for you to start creating test for a Web Service the same time you start to develop the same Web Service. This means, when the real Web Service is ready for testing; you can already have the tests done. This can be extremely powerful and will make it possible to work according to Test Driven or Agile Methodologies.

In soapUI you can create a MockService simply by choosing to add a Web Service Request to a MockService in order for the MockService to listen to it. Or you can even right click the Interface Icon and choose "Generate MockService", which will generate a MockService containing each defined response in the Interface.

You can then choose how to Respond to the Request and choose how to Dispatch (send out) different responses.

Now, let's take a look at how the Mock Service works. Open the MockService, called SampleServiceSoapBinding MockService, by double clicking on it.

Browse through the different Interfaces in the MockService; login, logout, search, and buy, and see what we do with different requests. As you see all the requests are dispatched using scripts. This is by far the most common way of dispatching, but early on in a project you might just want to create a set of responses and dispatch them in sequence or at random.

You can start the MockService by pressing the MockService Start button.

Web Service Inspection

Web Service Inspection a fancy way of saying looking at the Web Service. Good support for Web Service inspection can be very important early in the project when you want to find out how a Web Service.

Inspecting the Web Service can be done in two ways; inspecting the Web Service and making Web Service requests.
Inspect the WSDL

You can inspect a WSDL by Double Clicking Interface Icon. You then get the Interface Viewer, a very useful tool for seeing what the WSDL contains and how it is structured.

This is a structured way of looking at your WSDL. Just browsing the XML of the WSDL is very cluttered and a WSDL often is to complicated too look at in its entirety and therefore it is seldom done, resulting in lower WSDL understanding. In other words, since WSDL's are so complicated people don't read it, and remember, the WSDL is the specification (contract actually, bet let's not get into that...) and how well you use it depends on how well you understand it. This is a serious problem early on in projects, the people in the project don't understand the Contract. The soapUI Interface Viewer is a great tool for solving this problem.

Now let's Inspect the Web Service. Inspect the Sample Project WSDL by double clicking the SampleServiceSoapBinding Interface Icon. Use the Interface Viewer to familiarize yourself with the WSDL, the move on to Web Service Requests.
Make Service Requests

Expand the login Interface and double click the login request. Login by using the username Login and the password Login123. You should now have gotten the response containing a sessionID 9575658833177431

Go ahead, try it!

No response? don't forget to start the MockService. We also need to copy the sessionID and use it to logout.
Functional Tests
Test Structure

Let's move on and look at how tests work in soapUI. We have created three different TestSuites all containing different TestCases. A TestCase is made up of several steps, called TestSteps. The structure of a soapUI project is like this;

    * Project
    * Interface
    * TestSuites
          o TestCases
                + TestSteps
                + LoadTests
    * MockServices

As you can see there is also something called LoadTests, we can gather what they are, but we'll go into detail more what they actually do and how they actually work later.
Functional Tests in detail

Now let's examine a Functional Test in a TestCase. Expand the TestSuite Sample Simple TestSuite and then double click the TestCase Simple Login and Logout w. Properties Steps. As you can see the case consists of 5 TestSteps.

You can also click the Description tab in order to see the in test documentation.

The step consists of three different types of TestSteps; One PropertyStep, Two Test Requests and Two PropertyTransfer Steps. This is what they do:

    * PropertySteps: Stores Properties for later use. In our case it's the Username and Password required to login.
    * Test Requests: The actual requests to the server. In this case login and logout.
    * PropertyTransfers: A step used for moving properties between different steps. This might be from a Property Step to a request like the step Property Transfer: Move Username and Password does, or to move properties from a Test Request to another, like the step Property Transfer: Move sessionID does.

Functional Tests continued

Double Click on each step and examine how they work. Double Click the TestSteps and you'll get the TestStep editor. You can for example see that the step Property Transfer: Move Username and Password moves does two transfers in two Properties.

    * First it takes does the TransferUser Transfer. It takes the Property Username from the step Properties: Username and Password and moves it to the step Test Request: login.
    * Then it takes does the TransferPass Transfer. It takes the Property Password from the said step Properties: Username and Password and also moves it to the step Test Request: login.

Assertions

An important feature in Test is the assertions in Test Requests. Open the Test Step Test Request: logout.

In the TestStep we have four assertions, all asserting different things; That the response is a SOAP response, that it complies with the schema, that is isn't a SOAP fault and something called an XPATH match. The XPath Match validates that a certain element has the value expected.

The Test Run

Now that we have examined the TestCase, let's run it! Press the Play Button and the Test will run and the Test Case progress bar should be full and green.

Does it turn red after only a step?

Don't forget to start the MockService.

Or... did you run the TestStep earlier?

Look at the response, maybe the response is that you already have a session?

We logged in earlier and aren't allowed to log in again, let's just go to the MockService, stop it and restart it, clearing any server side sessions. Now, rerun the test.
Load Tests

Something very useful in soapUI is the ability to quickly create LoadTests. Why is this useful? The earlier you are able to run load tests, the earlier you can discover any performance issues. In soapUI you create a LoadTest simply by choosing a functional test, right clicking it and saying New LoadTest. Done!

This makes soapUI LoadTest extra good since the immediately enable you to load test the functionality not that the Web Service can respond quickly to the same Request over and over again. LoadTests are byproducts of the Functional Tests.

Now, let's examine a Load Test!

Go to the TestSuite Sample expanded TestSuite and the TestCase Search and Buy TestCase. There you will find for LoadTests, one for each LoadTest strategy. Choose the Simple Strategy LoadTest. The simple strategy is a basic strategy with a random delay.

The first figure to configure is the Test Delay, this sets the number of milliseconds our base delay will be (1000 is one second). The second figure is the random variable which sets how the delay should be changed at random, the value 0.5 means it should be half, that is between 500 and 1000 milliseconds.

What would the value 0 mean? That's right no random delay at all, just 1000 milliseconds all the time.

Now, let's run it!

As you see the numbers of the test are continuously updated. You can see figures like the response times throughput per second (tps) assertions errors and more. You can also press the graph button and see a graph of the test run.

Read more about the Interface here and the different strategies here.

You can also do LoadTest Assertions. One of the more important is the Max Errors Step. This is used for allowing the maximum number of errors allowed in a test run.

This will lead us to the final example, discovering an error in our MockService.
An error in our MockService

Go to the TestSuite Sample TestSuite fails if we don't get faults and the TestCase TestCase: Searching after Logging out LoadTests. There you will find a load test called LoadTest with Multiple Tests (will fail). Open it and run it. After a time this test will fail

Why?

Because multiple users are simultaneously logging in with the same username, which is not allowed by the MockService

Go ahead, try it!

Continuation

Now you can continue running the tests and look at different ways of doing tests.

Enjoy!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2008-2-21 22:24:35 | 只看该作者
这个工具和loadrunner  webservice 协议作性能测试相比有何好处。
请楼上介绍介绍
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2008-2-22 10:03:58 | 只看该作者

回复 2# 的帖子

最大的好处是soapui是开源滴,免费滴
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2008-2-22 10:18:59 | 只看该作者
lz是否使用过了该工具?能否介绍下使用心得,呵呵
回复 支持 反对

使用道具 举报

该用户从未签到

5#
 楼主| 发表于 2008-2-22 10:46:47 | 只看该作者

回复 4# 的帖子

我只是用了soapUI做了webservice的功能测试,感觉比较好上手,因为大多数测试人员包括我不懂webservice很难读懂其中代码意思
性能测试方面没有用过,但看了介绍觉得可以应用于测试webservice的简单的性能测试
功能当然没有LR强大各种性能测试都能测,但对于webservice的针对性较强,如果公司需要专门对于webservice进行测试,不妨可以用用看
回复 支持 反对

使用道具 举报

该用户从未签到

6#
发表于 2009-2-20 19:27:09 | 只看该作者

学习中

刚刚在学习,感觉比用jmeter的简单,但是我弄了半天不知道怎么进行参数化,sigh,楼主是不是我理解上有问题啊,我把WSDL导进去之后,然后看到了很多参数是问号的,不知道要怎么进行参数。赐教赐教
回复 支持 反对

使用道具 举报

该用户从未签到

7#
发表于 2009-3-30 11:33:01 | 只看该作者
原帖由 jessies 于 2009-2-20 19:27 发表
刚刚在学习,感觉比用jmeter的简单,但是我弄了半天不知道怎么进行参数化,sigh,楼主是不是我理解上有问题啊,我把WSDL导进去之后,然后看到了很多参数是问号的,不知道要怎么进行参数。赐教赐教

参数是由开发人员提供的。
回复 支持 反对

使用道具 举报

该用户从未签到

8#
发表于 2009-9-3 22:24:48 | 只看该作者
的法國和
回复 支持 反对

使用道具 举报

该用户从未签到

9#
发表于 2009-9-4 11:59:30 | 只看该作者
图形界面没有lr好
回复 支持 反对

使用道具 举报

该用户从未签到

10#
发表于 2009-9-28 21:23:01 | 只看该作者
请问搂住 你的是那个版本的阿  装的是JDK1.5 还是 1.6 阿,  是下载解压后双击SoapUi.bat  就可以了么  ,  可是我双击第一次是可以的, 关掉后在双击就不起作用了, 为啥阿?
回复 支持 反对

使用道具 举报

该用户从未签到

11#
发表于 2010-4-16 23:54:48 | 只看该作者
环境配置有问题吧
回复 支持 反对

使用道具 举报

该用户从未签到

12#
发表于 2010-12-30 14:37:38 | 只看该作者
那位哥哥能告诉怎么把字符串参数化
回复 支持 反对

使用道具 举报

该用户从未签到

13#
发表于 2012-3-8 10:56:20 | 只看该作者
刚才用了soapui测试了一下。用的是eclipse插件版本,很不稳定啊,容易崩溃,我使用的版本是:
eclipse 3.7,jdk 1.7;soapui-4.0.1?
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-22 19:27 , Processed in 0.105094 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表