zoukankan      html  css  js  c++  java
  • RobotFrameWork(十三)RobotFramework与loadrunner性能测试结合(基于Remote库)

    一般我们进行完功能测试,都需要进行下性能测试,那么这章我来介绍下,RobotFramework与loadrunner性能测试的融合,即运行完自动化功能测试,借助RobotFramework的Remote库来执行性能测试。

    13.1 准备条件

    A:一台pc,系统win7,安装有python、RobotFramework及ride。

    B:一台pc,安装有loadrunner,python,IP为192.168.8.231

    C:一台服务器

    13.2 结构图

    13.3步骤

    13.3.1 下载robotremoteserver.py(Remote Server)并修改

     Robotremoteserver.py为远程服务脚本,客户端通过它来调用服务器端的测试库来执行测试,下载地址如下:

    http://robotframework.googlecode.com/hg/tools/remoteserver/robotremoteserver.py

    Robotremoteserver.py中需要修改的地方,就是host和port:

    [python] view plain copy
     
    1. def __init__(self, library, host='192.168.8.231', port=8270, allow_stop=True):  
    2.     SimpleXMLRPCServer.__init__(self, (host, int(port)), logRequests=False)  
    3.     self._library = library  
    4.     self._allow_stop = allow_stop  
    5.     self._register_functions()  
    6.     self._register_signal_handlers()  
    7.     self._log('Robot Framework remote server starting at %s:%s'  
    8.                % (host, port))  
    9.      self.serve_forever()  

     修改: 设置host和port为安装loadrunner的测试机ip及端口

    13.3.2 创建远程测试库(Test Library)

    创建exampleremotelibrary.py脚本,脚本内容如下: 

    [python] view plain copy
     
    1. import os  
    2. import sys  
    3. class ExampleRemoteLibrary:  
    4.     """Example library to be used with Robot Framework's remote server. 
    5.  
    6.     This documentation is visible in docs generated by _libdoc.py_ 
    7.     starting from Robot Framework 2.6.2. 
    8.     """  
    9.   
    10.     def __init__(self):  
    11.         """Also this doc should be in shown in library doc."""  
    12.   
    13.     def run_performance_test(self,scriptname):  
    14.         run_pfm_str = ''  
    15.         run_pfm_list = ["wlrun.exe -TestPath ",scriptname," -port 8080 -Run -DontClose"]  
    16.         os.chdir("C:\Program Files (x86)\Hp\LoadRunner\bin")  
    17.         os.system(run_pfm_str.join(run_pfm_list))  
    18.   
    19. if __name__ == '__main__':  
    20.     from robotremoteserver import RobotRemoteServer  
    21.     RobotRemoteServer(ExampleRemoteLibrary(), *sys.argv[1:])  

    run_performance_test函数为调用loadrunner的wlrun.exe,执行给出的场景脚本。 

    13.3.3运行服务端测试库

     Exampleremotelibrary.py和Robotremoteserver.py都放置在安装loadrunner的PC上。

     在安装loadrunner的PC上执行如下命令:

      ‘python   exampleremotelibrary.py’

     

    13.3.4 用例写作及执行

    下面操作是在RobotFramework及ride安装的PC上。

    ①测试套(suite)中引入Remote

    注意:Remote后面的参数192.168.8.231:8270是测试执行机(安装loadrunner的PC)的ip及端口

    ②在用例中调用远程测试库

     我们调用run_performance_test这个函数,E:\loadrunner\Scenario1.lrs是性能测试的场景脚本:

    转至:https://blog.csdn.net/mengfanbo123/article/details/9042661

  • 相关阅读:
    远程rdp vnc连接 UBuntu 10.10
    解决develop.android.com无法访问到最佳方法
    Android系统源码编译全过程——下载Android源文件并编译
    SQL Server 2005配置sa登录和允许远程访问
    获取ItemTemplate值
    tab转Enter
    分布式事务
    google站内搜索
    在ASP.NET中动态生成图形(转)
    Transcation Scope,使代码块成为事务性代码
  • 原文地址:https://www.cnblogs.com/keepSmile/p/8657640.html
Copyright © 2011-2022 走看看