如何使用参数值列表? [英] How to use a list of values for a parameter?

查看:112
本文介绍了如何使用参数值列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS 2012的测试插件(尽管刚刚安装了2013),并且需要知道:

I am using the test plugin for VS 2012 (although have just installed 2013), and need to know:

在进行负载测试时,是否可以让参数传递与选定列表不同的值?

Is it possible to have a parameter pass a different value from a selected list while load testing?

我使用了位于此处的样本负载测试: http: //www.visualstudio.com/get-started/load-test-your-app-vs 并创建了一个新的网络测试,可以满足我的需求,如下所示.

I have used the sample load test located here: http://www.visualstudio.com/get-started/load-test-your-app-vs and created a new web test that meets my needs as below.

我记录了一个简单的旅程,即电子邮件注册网页.旅程实质上是完成姓名&地址,电子邮件,conf电子邮件,密码,conf密码.提交表单后,将发送一封验证电子邮件.

I have a simple journey recorded that is an email registration web page. The journey is essentially completing name & address, email, conf email, password, conf password. On submission of the form, a verification email is sent.

我需要检查此过程是否可以处理大约3000个用户.实际发送验证的电子邮件已被硬编码用于测试目的,但是我需要唯一的电子邮件来提交表单.我本质上希望运行3000个测试用例,并且每次都只更改电子邮件地址.

I need to check that this process can handle around 3000 users. The email to actually send the verification has been hardcoded for test purposes, but I need a unique email to submit the form. I would essentially like to run 3000 test cases through, and just change the email address each time.

做到这一点的最佳方法是什么?

What is the best way to do this?

推荐答案

简单的答案是对数据驱动(或数据驱动)Visual Studio Web性能测试进行网络搜索.您应该会找到许多文章和教程.

The simple answer is do a web search for data driving (or data driven) Visual Studio web performance tests. You should find many articles and tutorials.

详细信息:

首先,Visual Studio区分不同类型的测试. 加载测试是一种多次运行单个测试用例的方式,就像许多同时使用的用户一样,收集有关测试执行的数据并生成报告.负载测试可以执行的测试用例包括 Web性能测试编码的UI测试;这两个都可以由数据驱动.

Firstly, Visual Studio distinguishes different types of test. A Load Test is a way of running individual test cases many times, as if by many simultaneous users, gathering data about the test executions and producing a report. The test cases that a load test can execute include Web Performance Tests and Coded UI Tests; both of these can be data driven.

数据驱动 Web性能测试需要数据源.数据可以是CSV,XML,电子表格,数据库以及TFS中的数据.我将使用CSV进行描述.

Data driving a Web Performance Test requires a data source. The data can be CSV, XML, Spreadsheet, database and in TFS. I will describe using CSV.

创建一个CSV文件,其中包含与以下内容类似的内容.请注意,字段名称的第一行是必需的,并且在测试中使用了这些名称.

Create a CSV file, containing something similar to the following. Note that the top line of field names is required and those names are used within the test.

Name,Email,Telephone
Fred,fred@example.com,0123 456789
George,george@example.com,0123 456790
Harry,harry@example.com,0123 456791

另请参见 CodedUI测试无法从CSV输入读取数据文件(用于创建一些便笺CSV文件).

See also CodedUI test does not read data from CSV input file for some notes CSV file creation.

在Visual Studio中打开测试项目,然后打开用于测试的.webtest文件.使用测试顶部节点的上下文菜单(右键单击),即测试名称(或使用相应的图标),然后选择添加数据源...".按照提示将CSV文件添加到项目中.

Open the test project in Visual Studio and open the .webtest file for the test. Use the context (right-click) menu of the top node of the test, ie the test's name (or use the corresponding icon) and select "Add data source ...". Follow the prompts to add the CSV file into the project.

Web性能测试中,展开请求以显示表单参数或查询字符串或使用数据的任何内容.查看相关字段的属性面板,然后选择适当的属性,在许多情况下,它是Value属性.单击小三角形为属性选择一个值.弹出窗口应显示数据源,展开显示的项目并选择必填字段.选择该字段后,该属性将显示一个值,例如{{DataSource1.FileName#csv.Email}}.大括号({{}})加倍表示使用上下文参数.所有已使用数据源字段都可以用作上下文参数.通过更改数据源文件的选择列属性,可以使所有数据源字段可用.通过使用诸如

Within the Web Performance Test expand the request to show the form parameters or query string or whatever that is to use the data. View the properties panel of the relevant field and select the appropriate property, in many cases it is the Value property. Click the little triangle for choosing a value for the property. The popup should show the data source, expand the items shown and select the required field. After selecting the field the property will show a value such as {{DataSource1.FileName#csv.Email}}. The doubled curly braces ({{ and }}) indicate the use of a context parameter. All the used data source fields are available as context parameters. All of the data source fields can be made available by altering the Select Columns property of the data source file. Data source field can be used as part of a property value by using values such as

SomeText{{DataSource1.FileName#csv.Email}}AndMoreText

数据源访问方法

可以以四种方式读取和使用来自数据源的数据.默认值为顺序.使用解决方案资源管理器选择其他订单以访问文件的属性(例如FileName#csv). 访问方法属性可以设置为以下其中一项:

Data source access methods

The data from the datasource can be read and used in four ways. The default is Sequential. Other orders are selected using Solution Explorer to access the properties of the file (eg FileName#csv). The Access Method property can be set to one of:

顺序数据通过文件顺序读取.读取文件的最后一行后,文件的第一行将是要读取的下一行.因此,每一行可能会被读取多次.

Sequential data is read sequentially through the file. After the last line of the file is read, the first line of the file will be next line to be read. Thus each line may be read more than once.

随机数据是随机读取的.

唯一数据.读取文件末尾后,将不再执行测试.因此,每行只能读取一次.

Unique data is read sequentially through the file. After the end of the file is read the test will not be executed again. Thus each line in can only be read once.

请勿自动移动光标,该测试用于通过插件调用来移动光标的更复杂的测试.

Do not move cursor automatically intended for more complex tests where the cursor is moved via calls from plugins.

一个网络测试可能使用多个数据源文件.这些文件可能具有不同的访问方法.例如,可以依次访问一个包含登录名和密码的文件,而随机访问另一个包含其他数据的文件.这样一来,每次登录即可尝试其他数据的许多不同集合.

A web test may use more than one data source file. These files may have different access methods. For example one file containing login names and passwords could be accessed Sequentially and another file with other data could be accessed Randomly. This would allow each login to try many different sets of the other data.

Web性能测试可能包含循环.循环的属性包括高级数据游标.例如,这允许数据源文件包含要查找的项目并将其添加到购物篮,以便每次循环迭代都添加一个新项目.

Web performance tests may contain loops. The properties of a loop include Advance data cursors. This allows, for example, a data source file to contain items to be found and added to a shopping basket such that each loop iteration adds a new item.

这篇关于如何使用参数值列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆