LoadRunner 参数化之 连接数据库进行参数化

时间:2023-03-08 23:47:00
LoadRunner 参数化之 连接数据库进行参数化

LoadRunner 参数化之 连接数据库进行参数化

Loadrunner(简称“LR”)对性能测试的脚本进行参数化时,由于数据量偏大,大家往往都会把数据录入到数据库表里,然后关联到LR,本文将详细介绍LR连接数据库数据进行参数化的方法

工具/原料

  • HP LoadRunner 11
  • sql sever 2008

百度经验:jingyan.baidu.com

方法/步骤

  1. 1

    首先,选中你要参数化的部分,比如我选择的是登陆时候的UserName,我的用户名是 “admin”,那我选中“admin”,右键,选择“替换为参数”

  2. 2

    第二步,更改参数名称,这里我改成了“UserData”,然后点“属性”链接

  3. 3

    第三步:在弹出框里,选择“数据向导”

  4. 4

    第四步:选择“手动指定SQL语句”

  5. 5

    第五步:选择“创建”

  6. 6

    第六步:选择“机器数据源”页签,并选择“创建”

  7. 7

    第七步:选择“系统数据源”

  8. 8

    第八步:选择本机安装数据库的驱动,因为我新建的数据库在sql 2008上,所以我选择的是最下面的

  9. 9

    第九步:直接完成

  10. 10

    第十步:查看数据库连接引擎里的服务器名称

  11. 11

    第十一步:输入你建立的数据库名称

  12. 12

    第十二步:输入SQL验证的用户名和密码

  13. 13

    第十三步:选中新建的数据库

  14. 14

    第十四步:选择完成

  15. 15

    第十五步:此处是你选择数据库的相关信息

  16. 16

    第十六步:点击完确定后,你将会看到在”机器数据源“页签下,多了一个你刚建的系统数据库,然后选中它

  17. 17

    第十七步:选中后,在弹出的框内 输入sql 验证的sa密码

  18. 18

    第十八步:这样的话,数据库连接串就建立完毕,在下面输入你的数据库表查询语句即可

  19. 19

    第十九步:点击”完成“后,将会看到数据库的值已经加入到参数列表

  20. 20

    附录:我的数据库表的结构

    LoadRunner 参数化之 连接数据库进行参数化

    loadrunner 数据库参数化

    loadrunner可以参数化一些参数,其中一种可以用直接连接数据库取值的方式: 选中参数,右键:Replace with Paramater,选择type,点击Properties: LoadRunner 参数化之 连接数据库进行参数化 点Data Wizard后可以设置数据库: LoadRunner 参数化之 连接数据库进行参数化LoadRunner 参数化之 连接数据库进行参数化LoadRunner 参数化之 连接数据库进行参数化LoadRunner 参数化之 连接数据库进行参数化LoadRunner 参数化之 连接数据库进行参数化
    下一步后,点Create-->机器数据源-->新建-->系统数据源-->下一步:
    1、postgres数据库: 选择你需要的数据源(如:PostgresSQL ODBC Driver(UNICODE))-->下一步-->完成: LoadRunner 参数化之 连接数据库进行参数化
    这时可以点击Test查看你的数据库配置是否正确 这些做完后,输入sql语句,Finish即可: LoadRunner 参数化之 连接数据库进行参数化 2、oralce数据库: 先安装oracle客户端,其间有建立Net服务名 (前面跟postgres数据库一样,然后)选择你安装的oracle: LoadRunner 参数化之 连接数据库进行参数化
    -->下一步-->完成 LoadRunner 参数化之 连接数据库进行参数化

    -->Data Source Name:the name used to identify the data source to ODBC. For example, "odbc-pc". You must enter a Data Source Name.

    Description - a description or comment about the data in the data source. For example, "Hire date, salary history, and current review of all employees." The Description field is optional.

    TNS Service Name - the location of the Oracle database from which the ODBC driver will retrieve data. This is the same name entered in configuring network database services using the Oracle Net Manager. For more information, see the Oracle Net Services documentation and Using the Oracle ODBC Driver for the First Time. The TNS Service Name can be selected from a pulldown list of available TNS names. For example, "ODBC-PC". You must enter a TNS Service Name.

    User ID - the user name of the account on the server used to access the data. For example, "scott". The User ID field is optional.
    -->点击:Test Connection看是否可以连接 LoadRunner 参数化之 连接数据库进行参数化
    -->输入用户名密码-->OK-->OK LoadRunner 参数化之 连接数据库进行参数化
    -->选择你的数据库源名称,然后确定 -->输入用户名密码 LoadRunner 参数化之 连接数据库进行参数化
    在SQL statement框里输入你要查询的sql语句:Finish就OK了