• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

利用LR测试程序基类的性能

发布: 2008-9-11 14:46 | 作者: allen | 来源: 51testing | 查看: 193次 | 进入软件测试论坛讨论

领测软件测试网

在VUSERCLASS中写方法,在METHOD中写参数调用,等于参数化了。

VuserClass代码如下 :

using System;
using System.Collections;
using System.Diagnostics;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Data;
using System.Web;
using System.Reflection;

using Common;
using Proxy;
using DAT;
using ShangXin;
using ShangXin.Data;
using ShangXinInterface;
namespace LRQueryCustomer
{
 ///


 /// Summary description for VuserClass.
 ///

 [ClassInterface(ClassInterfaceType.AutoDual)]
 public class VuserClass
 { 
  public static string ifCanCreatePuDongOrderWithBiz = "";
  Proxy.LoginProxy loginProxy;
  Method methodLR = new Method();
  LoadRunner.LrApi lr;

  public VuserClass()
  {
   // LoadRunner Standard API Interface ::             DO NOT REMOVE!!!
   lr = new LoadRunner.LrApi();
  }

  // ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  public int Initialize()
  {
  try
   {
   RemotingConfiguration.Configure(@"D:\Escalade liunx\CODE_20051020100023\Code\OAERP\ShangXin.OAERP.App\bin\Debug\App.exe.config");

   lr.start_transaction("init");
   lr.start_transaction("GetLoginByLoginNameAndPassword");
   loginProxy = new LoginProxy();
   LoginData loginData = loginProxy.GetLoginByLoginNameAndPassword("administrator","");
   lr.end_transaction("GetLoginByLoginNameAndPassword",lr.PASS);

   Proxy.EmployeeProxy employeeProxy = new EmployeeProxy();
   CertificationInfo CI = new CertificationInfo();
   Common.CertificationInfo ci= PersonalCertificationInfo.GetCertificationInfo();

   CI.LoginName = SXConvert.ToString(loginData.Rows[0][LoginData.LOGINNAME]);
   CI.Password = SXConvert.ToString(loginData.Rows[0][LoginData.PASSWORD]);
   CI.EmployeeId = SXConvert.ToInt32(loginData.Rows[0][LoginData.EMPLOYEEID]);
   CI.EmployeeName = employeeProxy.GetEmployeeDataByPKID(SXConvert.ToInt32(loginData.Rows[0][LoginData.EMPLOYEEID])).Rows[0][EmployeeData.NAME].ToString();
   CI.RecordCount = SXConvert.ToInt32(loginData.Rows[0][LoginData.RECORDCOUNT]);

   lr.start_transaction("GetAllAuthsByLoginId");
   int loginID = SXConvert.ToInt32(loginData.Rows[0][LoginData.PKID]);
   AuthData ad = loginProxy.GetAllAuthsByLoginId(loginID);
   methodLR.SetAuth(ad,CI);
   lr.end_transaction("GetAllAuthsByLoginId",lr.PASS);

   lr.start_transaction("GetGroupsByLoginID");
   GroupData groupData = loginProxy.GetGroupsByLoginID(loginID);
   methodLR.GetGroupAuth(groupData,CI);
   lr.end_transaction("GetGroupsByLoginID",lr.PASS);

   lr.start_transaction("AddToCurrentEmployee");
   if (AuthenticationManager.CheckAuthentication(CI,EnumAuthority.AuthLoginSystem))
   {
    methodLR.AddToCurrentEmployee(ci,CI);
    lr.end_transaction("AddToCurrentEmployee",lr.PASS);
    DataRow BizDR = new SystemParameterValueProxy().GetSystemParameterValueByParentCode(SystemParametersCode.CANCREATEPUDONGORDERWITHBIZ,Bools.TRUE).Rows[0];
    ifCanCreatePuDongOrderWithBiz = BizDR[SystemParameterValueData.OTHER1].ToString();
   }
   else
   {
    lr.end_transaction("AddToCurrentEmployee",lr.FAIL);
   }
  
   lr.end_transaction("init",lr.PASS);
  }
  catch(Exception ex)
  {
   string error = ex.Message;
  }
   return lr.PASS;

  }

  // ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  public int Actions()
  {
   
   #region 查询客户
   //条件为空查询
   try
   {
    lr.start_transaction("GetCustomerCountByCondition");
    object[] param = {methodLR.GetQueryCustomerConditions()};

    Object obj = System.Activator.CreateInstance(typeof(Proxy.CustomerProxy));
    MethodInfo method = obj.GetType().GetMethod("GetCustomerCountByCondition");
    DataTable dt = (DataTable)method.Invoke(obj,param);
    int count = Convert.ToInt32(dt.Rows[0][0]);

    if(count>0)
     lr.end_transaction("GetCustomerCountByCondition",lr.PASS);
    else
     lr.end_transaction("GetCustomerCountByCondition",lr.FAIL);
   }
   catch(Exception ex)
   {
    string error = ex.Message;
   }

   //按客户编号查询
   try
   {
    lr.start_transaction("GetCustomerCountByCode");
    object[] param1 = {methodLR.GetQueryCustomerByCodeConditions()};

    Object obj1 = System.Activator.CreateInstance(typeof(Proxy.CustomerProxy));
    MethodInfo method1 = obj1.GetType().GetMethod("GetCustomerCountByCondition");
    DataTable dt1 = (DataTable)method1.Invoke(obj1,param1);
    int count1 = Convert.ToInt32(dt1.Rows[0][0]);

    if(count1>0)
     lr.end_transaction("GetCustomerCountByCode",lr.PASS);
    else
     lr.end_transaction("GetCustomerCountByCode",lr.FAIL);
   }
   catch(Exception ex)
   {
    string error = ex.Message;
   }

   //按客户名称查询
   try
   {
    lr.start_transaction("GetCustomerCountByCustomerName");
    object[] param2 = {methodLR.GetQueryCustomerByCustomerName()};

    Object obj2 = System.Activator.CreateInstance(typeof(Proxy.CustomerProxy));
    MethodInfo method2 = obj2.GetType().GetMethod("GetCustomerCountByCondition");
    DataTable dt2 = (DataTable)method2.Invoke(obj2,param2);
    int count2 = Convert.ToInt32(dt2.Rows[0][0]);

    if(count2>0)
     lr.end_transaction("GetCustomerCountByCustomerName",lr.PASS);
    else
     lr.end_transaction("GetCustomerCountByCustomerName",lr.FAIL);
   }
   catch(Exception ex)
   {
    string error = ex.Message;
   }

  

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/

TAG: 程序 基类 性能

31/3123>

关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网