发布新日志

  • (转载)RFT-Manual Verification Point

    2008-12-19 15:15:07

    Rational Functional Tester(以下简称RFT)是一款强大易用的自动化功能测试工具。在使用RFT进行功能测试的过程中,测试结果的验证往往是通过插入验证点(Verification Point)来完成的。但是RFT的验证点只能验证有限的数据类型,而在实际应用中,对用户自定义类型的验证存在着较大的需求。本文对验证点的验证执行过程进行剖析,并介绍如何通过自定义ValueManager来实现对用户自定义类型对象的验证。

    1验证点简介

    1.1 验证点的类型

    Rational Functional Tester是Rational最新推出的自动化功能测试工具。RFT具有数据驱动(Data-Driven)测试、scrīptAssure等特性,因而受到广大功能测试人员的青睐。在RFT中,验证点是脚本(scrīpt)中非常重要的组成部分,它完成对被测试程序生成的实际数据和期望数据的比较,并将比较结果写入日志。一般情况下,测试的结果是通过对验证点的执行而得到的。

    RFT提供了多种形式的验证点,包括:

    静态验证点(Static Verification Point):静态验证点是在录制(Record)RFT脚本的过程中通过向导插入的验证点,它在脚本回放(Playback)的过程中自动被验证。

    手动验证点(Manual Verification Point):如果验证点所要验证的内容是由脚本开发人员在脚本中所提供的,则需要建立手动验证点对其进行验证。例如待验证数据来自外部数据源的情况,脚本开发人员需将数据读取后以参数的形式显式传给验证点。

    动态验证点(Dynamic Verification Point):动态验证点是在脚本首次回放时建立的。验证点一旦建立,其行为就和静态验证点相同了。

    如果以录制-回放(Record-Playback)模式使用RFT进行图形界面(GUI)的自动化回归测试(Regression Test),较常用的是静态验证点。而由于RFT的数据驱动测试特性以及与其他RUP工具的良好集成,使之也是非图形化界面的功能测试的首选工具之一。在这些测试用例中,存在着大量的用户自定义类型对象,这些被测试对象并不能在录制过程中被插入对象映射表(ObjectMap)中,也就是不能使用静态验证点来进行验证,这就需要我们使用手动验证点来比较它们。

    1.2 验证点执行过程

    在RFT中,手动验证点有两种声明形式:

    • IFtVerificationPoint vpManual (java.lang.String vpName, java.lang.Object actual)

      该声明接受两个参数,第一个参数为验证点的名称,第二个参数为被测试对象。可以通过如下方式在脚本中调用该方法:

      vpManual("VP1", "The object under test").performTest();
      

      这条语句的作用就是判断被测试对象和基准线(Baseline)是否一致。这里所说的基准线就是期望数据,它以XML格式被存储在磁盘上,后缀名rftvp。

      当回放脚本时,如果基准线所对应的文件已经在磁盘上存在,则RFT会比较被测试对象和基准线中的数据是否一致,如果一致,则测试结果为成功(Pass),否则为失败(Failed);如果基准线尚不存在,则会以当前被测试对象作为基准线存入磁盘。

    • IFtVerificationPoint vpManual (java.lang.String vpName, java.lang.Object expected, java.lang.Object actual)

      手动验证点的另一种声明接受三个参数,第一个参数为验证点的名称,第二个参数则为期望数据,第三个参数为实际数据,也就是被测试对象。可以通过如下方式在脚本中调用该方法:

      vpManual("VP1", "Expected object", "The object under test").performTest();
      

      当脚本回放时,RFT直接比较期望数据和实际数据,并将比较的结果被写入日志。总的来说,验证点的执行过程如图1所示:


      图1 验证点执行流程图
      图1 验证点执行流程图

    不难看出,在执行验证点的过程中,涉及到了将数据写入磁盘以及从磁盘中恢复数据的操作。将这些数据写入磁盘便于测试人员使用工具查看和编辑。但是这也带来了一个问题,对于开发者自定义类型的对象,哪些属性需要被写入磁盘,这些属性按照什么顺序写入都是类型相关的,需要脚本开发者自行定义。更重要的,如何比较自定义类型也是RFT所不能确定的,换句话说,脚本开发者需要告知RFT对象一致的标准。以上这两个任务都需要通过创建ValueManager来完成。

    ValueManager可以用类特定(Class-specific)的形式比较和持久化用户自定义的对象。它是IManageValueClass接口的实现。只有拥有自己的ValueManager的类型才能作为参数传递给vpManual。这些类型被称为基于Value-class的类型。缺省的,只有基本数据类型,String,Vector等少数类型才是基于Value-class的类型那么,如何才能实现我们自己的ValueManager呢?在下面的章节中,我们将通过一个实例来帮助您建立自定义类型的ValueManager。





    回页首


    2. 实例分析--如何实现ValueManager

    2.1需求的提出

    假设我们需要验证一个计算图形重心的算法。该算法的输出结果为一个自定义类型MyPoint,它表示的一个平面上的点。它具有两个属性x,y,分别表示其横纵座标。MyPoint的实现如下,除了构造函数,它还提供了x和y的getter和setter方法。


    public class MyPoint {
    	
    	int x;
    	int y;
    	
    	public MyPoint(int x, int y) {
    		this.x = x;
    		this.y = y;
    	}
    	public int getX() {
    		return x;
    	}
    	public void setX(int x) {
    		this.x = x;
    	}
    	public int getY() {
    		return y;
    	}
    	public void setY(int y) {
    		this.y = y;
    	}
    }
    

    我们的测试人员需要判断该算法得到的重心点是否正确,可以使用了如下脚本:


    MyPoint point = getCenterOfGravity(polygon);
    vpManual("VP_CG", point).performTest();
    

    上面的语句将在第一次回放脚本时将得到的重心坐标写入磁盘;测试人员可以使用验证点编辑器查看得到的基准线是否正确;在此后的回放中(通常是回归测试中),上述代码的工作就是比较当次回归测试得到的重心对象与基准线是否一致。

    但是,如果直接调用该语句,RFT就会抛出异常(Unsupported type, value class required),说明MyPoint不是基于Value-class的类型。要使MyPoint成为Value-class,必须为其实现相应的ValueManager,并部署到RFT中。

    2.2其他验证自定义类型对象的方法

    在介绍如何实现ValueManager之前,首先让我们来看一下其他的解决办法。

    第一种方法,我们可以逐一比较自定义类型的属性来验证被测试对象是否符合要求。如下例所示:


    MyPoint point = getCenterOfGravity(polygon);
    vpManual("VP_CG1", new Integer(point.getX())).performTest();
    vpManual("VP_CG2", new Integer(point.getY())).performTest();
    

    使用logTestResult方法也可以达到同样的目的:


    MyPoint point = getCenterOfGravity(polygon);
    boolean flag = (point.getX() == 6 && point.getY()==8);
    logTestResult("This is not a VP", flag);
    

    这两种方式都有其局限性,第一种方式会使验证点的数量增加,特别是当自定义类的属性很多的时候;并且该方法也不利于重用,如果多个脚本都需要验证MyPoint,则脚本开发的工作会大大增加;第二种方式虽然不增加验证点数目,但是由于logTestResult只记录比较结果,使日志中的信息不足。特别是在测试用例失败的时候,这不利于测试人员定位问题所在。

    因而,为自定义类型实现ValueManager较以上两种方法更好。


    图3 使用ValueManager则可以通过验证点编辑器查看和编辑验证点数据,利于问题定位
    图3 使用ValueManager则可以通过验证点编辑器查看和编辑验证点数据,利于问题定位

    图4 使用logTestResult方法只能记录结果,不能记录数据,信息不足
    图4 使用logTestResult方法只能记录结果,不能记录数据,信息不足

    2.3创建ValueManager

    现在,我们准备创建MyPoint的ValueManager--我们命名为MyPointValue了,如上文所述,它是IManageValueClass接口的一个实现,该接口有7个方法:persistIn, persistInNamed, persistOut, compare, getCanonicalName, getClassName和createValue。这些接口分别完成哪些事情呢?

    我们再来看看,执行验证点的过程中ValueManager是怎么工作的。如图1所示,验证点执行过程中必须的步骤可以归为三类:读取数据--从基准线中读取数据;写入数据--将期望数据写入日志,将实际数据写入日志,写入基准线;比较--比较期望数据和实际数据。以上三类动作都需要ValueManager的参与。下面以MyPoint为例:

    如图5,在从基准线中读取数据的过程中,如果脚本发现基准线存在,RFT会读取基准线数据。如果RFT在注册了的ValueManager表中找到了相应的ValueManager--对MyPoint来说,就是找到了MyPointValue--就会创建该ValueManager的一个实例,然后调用该实例的persistIn方法。persistIn方法包含了如何读取MyPoint内容的逻辑,其返回值就是一个MyPoint对象,这样就将存储在磁盘上XML格式的MyPoint对象恢复出来,供RFT继续使用了。


    图5 从基准线中读取数据
    图5 从基准线中读取数据

    如图6,在写入数据的过程中,无论是写入期望数据,写入实际数据还是写基准线,都是通过persistOut方法完成的。同样的,RFT首先找到MyPoint的ValueManger,将其实例化,然后调用MyPointValue的persistOut方法将其写入磁盘。


    图6 写入基准线
    图6 写入基准线

    如图7,在比较两个MyPoint对象的时候,RFT还是先找到MyPoint的ValueManger,将其实例化,然后调用MyPointValue的compare方法,得到一个分值,根据分值和用户设置判断期望数据和实际数据是否一致。


    图7 比较期望数据与实际数据
    图7 比较期望数据与实际数据

    理解了IManageValueClass接口各方法的作用,我们就可以来实现这个ValueManager--MyPointValue了。如上文所述,有7个方法需要实现。其中最关键的是4个方法:

    • 持久化输出方法

      public void persistOut(Object obj, IPersistOut persistout,
        IAuxiliaryDataManager auxdatamanager)
      			

      该方法通过persistout将对象obj的属性写入到磁盘上。obj就是要写入的对象,persistout是负责写操作的接口,由RFT传入,auxdatamanager是用于命名相关文件的接口,由RFT传入,通常不是使用到这个参数。

      以MyPoint为例,下面的代码段将MyPoint的属性x,y依次记录到磁盘上:

      public void persistOut(Object obj, IPersistOut persistout,
      			IAuxiliaryDataManager auxdatamanager) {
      		if (obj instanceof MyPoint) {
      			MyPoint point = (MyPoint)obj;
      			// persistout是负责写的接口,
      //write方法接受的第一个参数是要写入的属性的名称
      //第二个参数是要写入的属性值
      			persistout.write("X", point.getX());
      			persistout.write("Y", point.getY());
      		}
      	}
      	

      对于测试开发人员来说,这里写入了哪些属性,将来哪些属性才能够被恢复出来。

    • 持久化恢复方法

      RFT提供两个方法读入持久化了的对象。一种接受IPersistIn类型的参数,另一种接受IPersistInNamed类型的参数。二者的不同在于,前者是根据对象属性的存储顺序进行读取的,而后者是按照对象的属性名称进行读取。以MyPointValue为例, 方法一的实现如下:

      public Object persistIn(IPersistIn persistin, IAuxiliaryDataManager auxdatamanager) {
      		// 在persistOut方法中,是按照x,y的先后顺序写入磁盘的,
      // 那么在该方法中就需要按照x,y的顺序将其读取出来read的参数就是写入磁盘的序号。
      		int x = ((Integer)persistin.read(0)).intValue();
      		int y = ((Integer)persistin.read(1)).intValue();
      		return new MyPoint(x, y);
      	}
      

      方法二的实现如下:

      public Object persistIn(IPersistInNamed persistinnamed, IAuxiliaryDataManager auxdatamanager) {
      	// 该方法根据persistOut时写入的属性名称读取属性,read的参数是属性名称
      		int x = ((Integer)persistinnamed.read("X")).intValue();
      		int y = ((Integer)persistinnamed.read("Y")).intValue();
      		return new MyPoint(x, y);
      	}
      

    • 比较方法

      public int compare(Object obj1, Object obj2, ICompareValueClass comparedvalueclass)
      

      compare方法用于确定两个对象一致与否,其前两个参数为要比较的对象,返回值则为一个0-100之间的整数,返回值越大则被比较的对象越相似。

      以MyPointValue为例,其比较原则是,如果二者相等则返回100(表示不同),否则返回0(表示相同)。

      public int compare(Object obj1, Object obj2, ICompareValueClass comparedvalueclass) {
      		if ((obj1 instanceof MyPoint) && (obj2 instanceof MyPoint)) {
      			MyPoint point1 = (MyPoint)obj1;
      			MyPoint point2 = (MyPoint)obj2;
      return (point1.getX()==point2.getX() && point1.getY()==point2.getY()) ? 100 : 0;
      		} else {
      			return 0;
      		}
      	}
      

    • 其他方法

      除上述四个方法,还有3个方法也需要实现,分别是

      public String getCanonicalName() { 
      		return "MyPoint";
      	}
      	

      上面的方法返回该Value-class的平台无关的规范名称

      public String getClassName() {
      		return "com.rational.ft.sample.MyPoint";
      	}
      	

      上面的方法返回ValueManager支持的Value-class的名称

      public Object createValue(Object sourceToCopy) {
      		return null;
      	}
      

      上面的方法返回被测试对象的一个拷贝,可以返回null,较少会被用到。

    2.4 部署ValueManager

    上面的7个方法实现了,MyPoint的ValueManager也就完成了。要在工程中使用ValueManger,还必须将ValueManager部署到RFT中。这也是注册ValueManger的过程。

    首先我们需要将ValueManager的实现导出为jar文件,例如vmsample.jar。

    第二步,我们还需要创建RFT自定义文件。RFT自定义文件是后缀名为RFTCUST的XML文件,用于定义开发者扩展的proxy,valuemanger等。RFT自定义文件内容如下,不难看出,其中ComponentModel元素中Obj一段是用于定义我们所创建的ValueManger的。ValueClass是要被验证的自定义类型;Manager是该自定义类型的ValueManger。


    <ConfigFile L=".ConfigFile">
    	<Section L=".ConfigFileSection">
    		<Name>valueManagers</Name>
    		<Val L=".ValueManagerManager">
    			<ComponentModel L=".ComponentModel">
    				<Name>Java</Name>
    				<Obj L=".ValueManager">
    					<Id>.MyPoint</Id>
    					<ValueClass>com.rational.ft.sample.MyPoint</ValueClass>
    					<Manager>com.rational.ft.sample.valuemanager.MyPointValue</Manager>
    				</Obj>
    			</ComponentModel>
    		</Val>
    	</Section>
    </ConfigFile>
    

    将.jar文件和RFTCUST建立好后,把这两个文件都放到C:\Documents and Settings\All Users\Application Data\ibm\RFT\customization目录下,ValueManager即被部署到RFT上了。(有可能需要重新启动计算机)





    回页首


    结论

    验证点是脚本的重要组成部分。对自定义类型的验证又是测试中所不可避免的。通过开发ValueManager来扩展RFT对自定义类型验证的支持,较之其它方法可重用性好,并使信息能够在日志中一目了然,而且便于修改期望数据。这一特性使RFT的应用更加自由。

  • (转载)Java资源

    2008-12-19 10:44:22

    Java Learning Path (一)、工具篇 
    一、
     JDK (Java Development Kit) 

    JDK
    是整个
    Java的核心,包括了Java运行环境(Java Runtime Envirnment),一堆Java工具和Java基础的类库(rt.jar)。不论什么Java应用服务器实质都是内置了某个版本的JDK。因此掌握JDK是学好Java的第一步。最主流的JDKSun公司发布的JDK,除了Sun之外,还有很多公司和组织都开发了自己的JDK,例如IBM公司开发的JDKBEA公司的Jrocket,还有GNU组织开发的 JDK等等。其中IBMJDK包含的JVMJava Virtual Machine)运行效率要比Sun JDK包含的JVM高出许多。而专门运行在x86平台的Jrocket在服务端运行效率也要比Sun JDK好很多。但不管怎么说,我们还是需要先把Sun JDK掌握好。 

    1
     JDK的下载和安装
     
    JDK
    又叫做J2SEJava2 SDK Standard Edition),可以从SunJava网站上下载到,http: //java.sun.com/j2se/downloads.html JDK当前最新的版本是J2SDK1.4.2,建议下载该版本的JDK,下载页面在这里:http://java.sun.com/j2se/1.4.2/download.html
     

    下载好的JDK是一个可执行安装程序,默认安装完毕后会在C:\Program Files\Java\目录下安装一套JRE(供浏览器来使用),在C:\j2sdk1.4.2下安装一套JDK(也包括一套JRE)。然后我们需要在环境变量PATH的最前面增加java的路径C:\ j2sdk1.4.2\bin。这样JDK就安装好了。
     

    2
     JDK的命令工具
     
    JDK
    的最重要命令行工具:
     
    java
     启动JVM执行
    class 
    javac
     Java编译器
     
    jar
     Java打包工具
     
    javadoc
     Java文档生成器
     
    这些命令行必须要非常非常熟悉,对于每个参数都要很精通才行。对于这些命令的
    学习JDK Documentation上有详细的文档。 


    二、
     JDK Documentation 

    Documentation
    JDK的下载页面也有下载连接,建议同时下载DocumentationDocumentation是最最重要的编程手册,涵盖了整个Java所有方面的内容的描述。可以这样说,学习Java编程,大部分时间都是花在看这个Documentation上面的。我是随身携带的,写Java代码的时候,随时查看,须臾不离手。
     


    三、 应用服务器
    (App Server) 

    App Server
    是运行Java企业组件的平台,构成了应用软件的主要运行环境。当前主流的App ServerBEA公司的 Weblogic ServerIBM公司的Websphere以及免费的Jboss,选择其中一个进行学习就可以了,个人推荐Weblogic,因为它的体系结构更加干净,开发和部署更加方便,是Java企业软件开发人员首选的开发平台。下面简要介绍几种常用的App Server
     

    1
     Tomcat 
    Tomcat
    严格意义上并不是一个真正的App Server,它只是一个可以支持运行Serlvet/JSPWeb容器,不过Tomcat也扩展了一些App Server的功能,如JNDI
    数据库连接池,用户事务处理等等。Tomcat被非常广泛的应用在中小规模的Java Web应用中,因此本文做一点下载、安装和配置Tomcat的介绍: 

    Tomcat
    Apache组织下Jakarta项目下的一个子项目,它的主网站是:http: //jakarta.apache.org/tomcat/ Tomcat最新版本是Tomcat4.1.27,软件下载的连接是:http: //www.apache.org/dist/jakarta/tomcat-4/binaries/ 
     

    下载Tomcat既可以直接下载zip包,也可以下载exe安装包(个人建议zip更干净些),不管哪种情况,下载完毕安装好以后(zip直接解压缩就可以了)。需要设置两个环境变量:
     

    JAVA_HOME=C:\j2sdk1.4.2 
    CATALINA_HOME=D:\tomcat4 (
    你的Tomcat安装目录


    这样就安装好了,启动Tomcat运行CATALINA_HOME\bin\startup.bat,关闭Tomcat运行 shutdown.bat脚本。Tomcat启动以后,默认使用8080端口,因此可以用浏览器访问http://localhost:8080
    测试 Tomcat是否正常启动。 

    Tomcat
    提供了两个Web界面的管理工具,URL分别是:
     
    http://localhost:8080/admin/index.jsp 
    http://localhost:8080/manager/html 
    在启用这两个管理工具之前,先需要手工配置一下管理员用户和口令。用一个文本工具打开CATALINA_HOME\conf\tomcat-users.xml这个文件,加入如下几行:
     

    <role rolename="manager"/> 
    <role rolename="admin"/> 
    <user username="robbin" password="12345678" roles="admin,manager,tomcat"/> 

    这样用户“robbin”就具备了超级管理员权限。重新启动Tomcat以后,你就可以使用该用户来登陆如上的两个管理工具,通过Web方式进行Tomcat的配置和管理了。
     

    2
     BEA Weblogic 
    Weblogic
    可以到BEA的网站上免费注册之后下载到最新的Weblogic8.1企业版,License可以免费使用1年时间,其实这已经完全足够了。Weblogic的下载连接:http://commerce.bea.com/index.jspWeblogic的在线文档: http://edocs.bea.com/ 
     

    3
     IBM Webshpere 
    Websphere
    同样可以下载到免费的试用版本,到IBMdeveloperWorks网站可以看到Websphere试用产品的下载和相关的Websphere的资料,developerWorks中文网站的连接是:http://www- 900.ibm.com/developerWorks/cn/wsdd/ Websphere的下载连接:http: //www7b.software.ibm.com/wsdd/downloads/WASsupport.html 
     

    4
     Jboss 
    Jboss
    是免费开源的App Server,可以免费的从Jboss网站下载:http: //www.jboss.org/index.html,然而Jboss的文档是不免费,需要花钱购买,所以为我们学习Jboss设置了一定的障碍。在 Jdon上有几篇不错的Jboss配置文档,可以用来参考:
    http://www.jdon.com/idea.html 


    四、 Java应用的运行环境
     

    Java
    的应用可以简单分为以下几个方面:
     

    1
     Java的桌面应用
     
    桌面应用一般仅仅需要JRE的支持就足够了。
     

    2
     Java Web应用
     
    Java
    Web应用至少需要安装JDK和一个web容器(例如Tomcat),以及一个多用户数据库,Web应用至少分为三层:
     
    Browser
    层:浏览器显示用户页面
     
    Web
    层:运行
    Servlet/JSP 
    DB
    层:后端数据库,向Java程序提供数据访问服务
     

    3
     Java企业级应用
     
    企业级应用比较复杂,可以扩展到n层,最简单情况会分为4层:
     
    Browser
    层:浏览器显示用户页面
     
    Client
    层:Java客户端图形程序(或者嵌入式设备的程序)直接和Web层或者EJB层交互
     
    Web
    层:运行
    Servlet/JSP 
    EJB
    层:运行EJB,完成业务逻辑运算
     
    DB
    层:后端数据库,向Java程序提供数据访问服务
     

    4
     Java嵌入式应用
     
    Java
    嵌入式应用是一个方兴未艾的领域,从事嵌入式开发,需要从Sun下载J2ME开发包,J2ME包含了嵌入式设备专用虚拟机KVM,和普通的JDK中包含的JVM有所不同。另外还需要到特定的嵌入式厂商那里下载模拟器。
     


    Java Learning Path
    (二)、书籍篇
     

    学习一门新的知识,不可能指望只看一本,或者两本书就能够完全掌握。需要有一个循序渐进的阅读过程。我推荐Oreilly出版的Java系列书籍。
     

    在这里我只想补充一点看法,很多人学习Java是从《Thinking in Java》这本书入手的,但是我认为这本书是不适合初学者的。我认为正确的使用这本书的方法应该是作为辅助的读物。《Thinking in Java》并不是在完整的介绍Java的整个体系,而是一种跳跃式的写作方法,是一种类似tips的方法来对Java很多知识点进行了深入的分析和解释。
     

    对于初学者来说,最好是找一本Java入门的书籍,但是比较完整的循序的介绍Java的语法,面向对象的特性,核心类库等等,在看这本书的同时,可以同步来看《Thinking in Java》,来加深对Java的理解和原理的运用,同时又可以完整的了解Java的整个体系。
     

    对于Java的入门书籍,蔡学镛推荐的是Oreilly的《Exploring Java, 2nd Edition 或者《Java in a Nutshell,2nd Edition(针对C++背景)》,我并没有看过这两本书。其实我觉得电子工业出版社的《Java 2编程详解》或者《Java 2从入门到精通》就很不错。
     

    在所有的Java书籍当中,其实最最有用的,并不是O'reilly Java Serials,真正最最有用处是JDK Documentation!几乎你想获得的所有的知识在Documentation里面全部都有,其中最主要的部分当然是Java基础类库的API文档,是按照package来组织的,对于每一个class都有详细的解释,它的继承关系,是否实现了某个接口,通常用在哪些场合,还可以查到它所有的 public的属性和方法,每个属性的解释,意义,每个方法的用途,调用的参数,参数的意义,返回值的类型,以及方法可能抛出的异常等等。可以这样来说,所有关于Java编程方面的书籍其实都不过是在用比较通俗易懂的语言,和良好的组织方式来介绍Documentation里面的某个package里面包含的一些类的用法而已。所以万变不离其宗,如果你有足够的能力来直接通过Documentation来学习Java的类库,那么基本上就不需要看其他的书籍了。除此之外,Documentation也是编程必备的手册,我的桌面上有三个Documentation的快捷方式,分别是J2SDK1.4.1 DocumentationServlet2.3DocumentationJ2SDKEE1.3.1Documentation。有了这个三个 Documentation,什么其他的书籍都不需要了。
     

    对于Java Web 编程来说,最核心的是要熟悉和掌握HTTP协议,这个就和Java无关了,在熟悉HTTP协议之后,就需要熟悉Java的实现HTTP协议的类库,也就是Servlet API,所以最重要的东西就是Servlet API。当然对于初学者而言,直接通过 Servlet API来学习Web编程有很大的难度,我推荐O'reilly的《Java Server Pages 》这本书来学习Web 编程。
     

    EJB
    的书籍当中,《Enterprise JavaBeans, 2nd Edition》是一本很不错的书, EJB的学习门槛是比较高,入门很难,但是这本书完全降低了学习的难度,特别重要的一点是,EJB的学习需要结合一种App Server的具体实现,所以在学习EJB的同时,必须同步的学习某种App Server,而这本书相关的出了三本书,分别是Weblogic6.1Websphere4.0JBoss3.0上面部署书中例子的实做。真是既有理论,又有实践。在学习EJB的同时,可以边看边做,EJB的学习会变得很轻松。
     

    但是这本书也有一个问题,就是版本比较旧,主要讲EJB1.1规范和部分EJB2.0的规范。而Ed Roman写的《Mastering EJB 2.0》这本书完全是根据EJB2.0规范写的,深入浅出,覆盖了EJB编程的各个方面,并且还有很多编程经验tips,也是学习EJB非常推荐的书籍之一。
     

    如果是结合Weblogic来学习J2EE的话,《J2EE应用与BEA Weblogic Server》绝对是首选读物,虽然是讲述的 Weblogic6.0,仍然值得购买,这本书是BEA官方推荐的教材,作者也是BEA公司的工程师。现在中文版已经随处可见了。这本书结合 Weblogic介绍了J2EE各个方面的技术Weblogic平台上的开发和部署,实践指导意义非常强。
     

    在掌握了Java平台基础知识和J2EE方面的知识以后,更进一步的是学习如何运用OO的方法进行软件的设计,那么就一定要学习设计模式 Sun公司出版了一本《J2EE核心模式》,是每个开发Java企业平台软件的架构师必备的书籍。这本书全面的介绍了J2EE体系架构的各种设计模式,是设计师的必读书籍。
     

    Java Learning Path
    (三)过程篇
     

    每个人的学习方法是不同的,一个人的方法不见得适合另一个人,我只能是谈自己的学习方法。因为我学习Java是完全自学的,从来没有问过别人,所以学习的过程基本上完全是自己摸索出来的。我也不知道这种方法是否是比较好的方法,只能给大家提供一点参考了。
     

     
    其实JDK的学习没有那么简单,关于JDK有两个问题是很容易一直困扰
    J学习Java的第一步是安装好JDK,写一个Hello World Java程序员的地方:一个是CLASSPATH的问题,其实从原理上来说,是要搞清楚JREClassLoader是如何加载Class的;另一个问题是packageimport问题,如何来寻找类的路径问题。把这两个问题摸索清楚了,就扫除了学习Java和使用JDK的最大障碍。推荐看一下王森的《Java深度历险》,对这两个问题进行了深入的探讨。 

    第二步是学习Java的语法。Java的语法是类C++的,基本上主流的编程语言不是类C,就是类C++的,没有什么新东西,所以语法的学习,大概就是半天的时间足够了。唯一需要注意的是有几个不容易搞清楚的关键字的用法,publicprotectedprivatestatic,什么时候用,为什么要用,怎么用,这可能需要有人来指点一下,我当初是完全自己琢磨出来的,花了很久的时间。不过后来我看到《Thinking in Java》这本书上面是讲了这些概念的。
     

    第三步是学习Java的面向对象的编程语言的特性的地方。比如继承,构造器,抽象类,接口,方法的多态,重载,覆盖,Java的异常处理机制。对于一个没有面向对象语言背景的人来说,我觉得这个过程需要花很长很长时间,因为学习Java之前没有C++的经验,只有C的经验,我是大概花了一个月左右吧,才彻底把这些概念都搞清楚,把书上面的例子反复的揣摩,修改,尝试,把那几章内容反复的看过来,看过去,看了不下5遍,才彻底领悟了。不过我想如果有 C++经验的话,应该一两天时间足够了。那么在这个过程中,可以多看看《Thinking in Java》这本书,对面向对象的讲解非常透彻。可惜的是我学习的时候,并没有看到这本书,所以自己花了大量的时间,通过自己的尝试和揣摩来学会的。
     

    第四步就是开始熟悉Java的类库。Java
    的基础类库其实就是JDK安装目录下面jre\lib\rt.jar这个包。学习基础类库就是学习rt.jar。基础类库里面的类非常非常多。据说有3000多个,我没有统计过。但是真正对于我们来说最核心的只有4个,分别是 
    java.lang.*; 
    java.io.*; 
    java.util.*; 
    java.sql.*; 

    这四个包的学习,每个包的学习都可以写成一本厚厚的教材,而O'reilly也确实是这样做的。我觉得如果时间比较紧,是不可能通过读四本书来学习。我觉得比较好的学习方法是这样的: 
    首先要通读整个package的框架,了解整个packageclassinterfaceexception的构成,最好是能够找到介绍整个包框架的文章。这些专门介绍包的书籍的前几章应该就是这些总体的框架内容介绍。 

    对包整体框架的把握并不是要熟悉每个类的用法,记住它有哪些属性,方法。想记也记不住的。而是要知道包有哪些方面的类构成的,这些类的用途是什么,最核心的几个类分别是完成什么功能的。我在给人培训的时候一般是一次课讲一个包,所以不可能详细的介绍每个类的用法,但是我反复强调,我给你们讲这些包的不是要告诉你们类的方法是怎么调用的,也不要求你们记住类的方法调用,而是要你们了解,Java给我们提供了哪些类,每个类是用在什么场合,当我遇到问题的时候,我知道哪个类,或者哪几个类的组合可以解决我的问题,That'all!,当我们具体写程序的时候,只要你知道该用哪个类来完成你的
    工作就足够了。编码的时候,具体的方法调用,是边写代码,边查Documentation,所有的东西都在Documentation里面,不要求你一定记住,实际你也记不住3000多个类的总共将近10万个方法调用。所以对每个包的总体框架的把握就变得极为重要。 

    第五步,通过上面的学习,如果学的比较扎实的话,就打好了Java的基础了,剩下要做的工作是扫清Documentation里面除了上面4个包之外的其他一些比较有用处的类。相信进展到这一步,Java的自学能力已经被培养出来了,可以到了直接学习Documentation的水平了。除了要做 GUI编程之外,JDK里面其他会有用处的包是这些: 
    java.text.*; 
    java.net.*; 
    javax.naming.*; 
    这些包里面真正用的比较多的类其实很少,只有几个,所以不需要花很多时间。 

    第六步,Java Web 编程 
    Web
    编程的核心是HTTP协议,HTTP协议和Java无关,如果不熟悉HTTP协议的话,虽然也可以学好Servlet/JSP编程,但是达不到举一反三,一通百通的境界。所以HTTP协议的学习是必备的。如果熟悉了HTTP协议的话,又有了Java编程的良好的基础,学习 Servlet/JSP简直易如反掌,我学习Servlet/JSP就用了不到一周的时间,然后就开始用JSP来做项目了。 

    Servlet/JSP的学习中,重头仍然是Servlet DocumentationServlet API最常用的类很少,花比较少的时间就可以掌握了。把这些类都看一遍,多写几个例子试试。Servlet/JSP编程本质就是在反复调用这些类来通过HTTP协议在Web Server Brower之间交谈。另外对JSP,还需要熟悉几个常用JSP的标记,具体的写法记不住的话,临时查就是了。 

    此外
    Java Web编程学习的重点要放在Web Application的设计模式上,如何进行业务逻辑的分析,并且进行合理的设计,按照 MVC设计模式的要求,运用ServletJSP分别完成不同的逻辑层,掌握如何在ServletJSP之间进行流程的控制和数据的共享,以及 Web Application应该如何配置和部署。 

    第七步,J2EE编程 
    以上的学习过程如果是比较顺利的话,进行到这一步,难度又陡然提高。因为上面的知识内容都是只涉及一个方面,而像EJBJMSJTA等核心的J2EE规范往往是几种Java技术的综合运用的结晶,所以掌握起来难度比较大。 

    首先一定要学习好JNDIJNDIApp Server定位服务器资源(EJB组件,DatasouceJMS)查找方法,如果对JNDI 不熟悉的话,EJBJMS这些东西几乎学不下去。JNDI其实就是javax.naming.*这个包,运用起来很简单。难点在于服务器资源文件的配置。对于服务器资源文件的配置,就需要看看专门的文档规范了,比如web.xml的写法,ejb-jar.xml的写法等等。针对每种不同的 App Server,还有自己的服务资源配置文件,也是需要熟悉的。 

    然后可以学习JTA,主要是要理解JTA对于事务的控制的方法,以及该在什么场合使用JTA。这里可以简单的举个例子,我们知道一般情况可以对于一个数据库连接进行事务控制(conn.setAutoCommit(false),....,conn.commit()),做为一个原子操作,但是假设我的业务需求是要把对两个不同数据库的操作做为一个原子操作,你能做的到吗?这时候只能用JTA了。假设操作过程是先往A数据库插一条记录,然后删除B 数据库另一个记录,我们自己写代码是控制不了把整个操作做为一个原子操作的。用JTA的话,由App Server来完成控制。 

    在学习EJB之前要学习对象序列化和RMIRMIEJB的基础。接着学习JMSEJB,对于EJB来说,最关键是要理解EJB是如何通过RMI来实现对远端对象的调用的,以及在什么情况下要用到EJB 

    在学习完EJBJMS这些东西之后,你可能会意识到要急不可待学习两个领域的知识,一个是UML,另一个是Design Pattern Java企业软件的设计非常重视框架(Framework)的设计,一个好的软件框架是软件开发成功的必要条件。在这个时候,应该开始把学习的重点放在设计模式和框架的学习上,通过学习和实际的编程经验来掌握EJB的设计模式和J2EE的核心模式。 

    J2EE
    规范里面,除了EJBJMSJTAServlet/JSPJDBC之外还有很多很多的企业技术,这里不一一进行介绍了。 

    另外还有一个最新领域Web ServicesWeb Services也完全没有任何新东西,它像是一种黏合剂,可以把不同的服务统一起来提供一个统一的调用接口,作为使用者来说,我只要获得服务提供者给我的WSDL(对服务的描述),就够了,我完全不知道服务器提供者提供的服务究竟是EJB 组件,还是.Net组件,还是什么CORBA组件,还是其他的什么实现,我也不需要知道。Web Services最伟大的地方就在于通过统一的服务提供方式和调用方式,实现了整个Internet服务的共享,是一个非常令人激动的技术领域。Web Services好像目前还没有什么很好的书籍,但是可以通过在网络上面查资料的方式来学习。 

    Java Learning Path
    (四) 方法篇 

    Java
    作为一门编程语言,最好的学习方法就是写代码。当你学习一个类以后,你就可以自己写个简单的例子程序来运行一下,看看有什么结果,然后再多调用几个类的方法,看看运行结果,这样非常直观的把类给学会了,而且记忆非常深刻。然后不应该满足把代码调通,你应该想想看如果我不这样写,换个方式,再试试行不行。记得哪个高人说过学习编程就是个破坏的过程,把书上的例子,自己学习Documentation编写的例子在运行通过以后,不断的尝试着用不同的方法实现,不断的尝试破坏代码的结构,看看它会有什么结果。通过这样的方式,你会很彻底的很精通的掌握Java 

    举个例子,我们都编过Hello World 

    public class HelloWorld { 
    public static void main(String[] args) { 
    System.out.println("Hello World"); 



    很多初学者不是很理解为什么main方法一定要这样来定义public static void main(String[] args),能不能不这样写?包括我刚学习Java的时候也有这样的疑问。想知道答案吗?很简单,你把main改个名字运行一下,看看报什么错误,然后根据出错信息进行分析;把mainpublic取掉,在试试看,报什么错误;static去掉还能不能运行;不知道main方法是否一定要传一个String[]数组的,把String[]改掉,改成int[],或者String试试看;不知道是否必须写args参数名称的,也可以把args改成别的名字,看看运行结果如何。 

    我当初学习Java的时候就是这样做的,把Hello World程序反复改了七八次,不断运行,分析运行结果,最后就彻底明白为什么了main方法是这样定义的了。 

    此外,我对于staicpublicprivateExceptiontry{ }catch {}finally{}等等等等一开始都不是很懂,都是把参考书上面的例子运行成功,然后就开始破坏它,不断的根据自己心里面的疑问来重新改写程序,看看能不能运行,运行出来是个什么样子,是否可以得到预期的结果。这样虽然比较费时间,不过一个例子程序这样反复破坏几次之后。我就对这个相关的知识彻底学通了。有时候甚至故意写一些错误的代码来运行,看看能否得到预期的运行错误。这样对于编程的掌握是及其深刻的。 

    其中特别值得一提的是JDK有一个非常棒的调试功能,-verbose 
    java –verbose 
    javac –verbose 
    以及其它很多JDK工具都有这个选项 
    -verbose 
    可以显示在命令执行的过程中,JVM都依次加载哪里Class,通过这些宝贵的调试信息,可以帮助我们分析出JVM在执行的过程中都干了些什么。 

    另外,自己在学习过程中,写的很多的这种破坏例程,应该有意识的分门别类的保存下来,在工作中积累的典型例程也应该定期整理,日积月累,自己就有了一个代码库了。遇到类似的问题,到代码库里面 Copy & Paste Search & Replace,就好了,极大提高了开发速度。最理想的情况是把一些通用的例程自己再抽象一层,形成一个通用的类库,封装好。那么可复用性就更强了。 

    所以我觉得其实不是特别需要例程的,自己写的破坏例程就是最好的例子,如果你实在对自己写的代码不放心的话,我强烈推荐你看看JDK基础类库的 Java源代码。在JDK安装目录下面会有一个src.zip,解开来就可以完整的看到整个JDK基础类库,也就是rt.jarJava源代码,你可以参考一下Sun是怎么写Java程序的,规范是什么样子的。我自己在学习Java的类库的时候,当有些地方理解的不是很清楚的时候,或者想更加清晰的理解运作的细节的时候,往往会打开相应的类的源代码,通过看源代码,所有的问题都会一扫而空。 

    Java Learning Path
    (五)资源篇 

    1
     http://java.sun.com/ (英文
    Sun
    Java网站,是一个应该经常去看的地方。不用多说。 

    2
    http://www-900.ibm.com/developerWorks/cn/ 
    IBM
    developerWorks网站,英语好的直接去英文主站点看。这里不但是一个极好的面向对象的分析设计网站,也是Web ServicesJava
    Linux极好的网站。强烈推荐!!! 

    3
    http://www.javaworld.com/ (英文
    关于Java很多新技术的讨论和新闻。想多了解Java的方方面面的应用,这里比较好。 

    4
    http://dev2dev.bea.com.cn/index.jsp 
    BEA
    的开发者园地,BEA作为最重要的App Server厂商,有很多独到的技术,在Weblogic上做开发的朋友不容错过。 

    5
    http://www.huihoo.com/ 
    灰狐动力网站,一个专业的中间件网站,虽然不是专业的Java网站,但是在J2EE企业应用技术方面有深厚的造诣。 

    6
    http://www.theserverside.com/home/ (英文
    TheServerSide
    是一个著名的专门面向Java Server端应用的网站。 

    7
    http://www.javaresearch.org/ 
    Java
    研究组织,有很多优秀的Java方面的文章和教程,特别是在JDO方面的文章比较丰富。 

    8
    http://www.cnjsp.org/ 
    JSP
    技术网站,有相当多的Java方面的文章和资源。 

    9
    http://www.jdon.com/ 
    Jdon
    论坛,是一个个人性质的中文J2EE专业技术论坛,在众多的Java的中文论坛中,Jdon一个是技术含量非常高,帖子质量非常好的论坛。 

    10
    http://sourceforge.net/ 
    SourgeForge
    是一个开放源代码软件的大本营,其中也有非常非常丰富的Java的开放源代码的著名的软件。

  • (转载)利用 Rational Functional Tester 实现 ITCL (或者 IBM) 框架

    2008-12-19 10:28:34

    框架

    IBM 框架以前被称作为 ITCL 框架,由质量软件工程(Quality Software Engineering) 和 IBM 中有经验的自动化团队合作开发而成的。这个框架由三层架构组成,架构的实现贯穿了应用对象、任务和测试用例包(IBM 包)。

    潜在于应用对象、任务和测试用例包之下的基本原理是:

    • 层次化的体系架构
    • 将“做什么”与“如何做”分离开来
    • 代码重用
    • 一致和清晰的组织结构
    • 快速增强的能力
    • 迅速的调试
    • 有效地组织文件
    • 启用协作
    • 学习他人

    下面是对应用对象、任务和测试用例的解释说明:

    • 应用对象:储存有关你的应用程序中的GUI元素信息。同时在这里也可以编写你的Getter 方法,这些 Getter 方法可以返回对象,使 调用者能够对这些GUI元素进行查询和操作。一般情况下,这些方法在Task层中进行调用。
    • 任务:在这里你将编写可重用的方法,这些方法在你的应用程序中执行通用功能。同时在这里,你将编写可以处理和查询复杂的特定应用程序控件的方法。在任务中的方法可以被测试用例调用。
    • 测试用例:导航一个应用程序,验证其状态,并记录其结果的方法。




    回页首


    实施方法论

    在本章节中概述的方法论详细说明了实施IBM框架的5个步骤。

    步骤1. 首先,在你的本地驱动器上创建一个新的项目。这个项目中有一个你可以储存、维护、编译和运行你的自动化代码的储存库。在Functional Tester中,选择File > New > Functional Test Project。给这个项目命名,并点击Finish

    步骤2. 将 IBM 的包― 它包括将在自动化脚本中广泛使用的工具类 ― 导入到你的项目中。尽管这可能只是简单地将路径关联到ibm.jar文件,但是将 IBM 的包导入到你的项目中就可以使你更容易地检查这个包的内容,然后在调试的时候进入到包中。这个IBM的包可以在这篇文章末尾的下载部分中进行下载。

    导入 ibm.jar 包

    1. 在 IBM Rational Functional Tester中,进入屏幕左边的Projects视窗,点击在步骤1中创建的项目
    2. 选择 File > Import。选择 Zip file 然后点击Next。使用Browse按钮在你储存这个文件的指定位置上查找ibm.jar 或者ibm.zip 文件。
    3. 保留所有默认设置并点击 Finish
    4. 你现在应该可以在Functional Test Projects视窗中扩展你项目的名称。你可以在它下面看到一个名为ibm的文件夹。

    步骤3. 创建一个名为AppObject的包

    1. 在IBM Rational Functional Tester中,进入屏幕左边的Projects视窗,在步骤1中创建的项目上点击。
    2. 选择File > New > New Test Folder
    3. 给文件夹命名为AppObject
    4. 点击Finish
    5. 重复1-4的步骤,创建TasksTestCase 文件夹

    什么是 AppObject 包?

    在这个包中你必须映射所有被测试应用的对象。一个最常见的建议是为每一个屏幕准备单独的脚本,以此确保更好的对象以及分类的的重用和组织。比如,创建一个名为login的脚本,它将使所有的对象跟login 界面保持相关。你同样可以创建其它与 sentinbox 界面等等相关的脚本。

    使用 AppObject 文件夹进行工作

    1. 在 AppObject 包中建立一个空脚本
    2. 选择 AppObject 包,点击右键并选择 Add Empty scrīpt,如图1所示。

    图1. 添加一个空脚本
    添加一个空脚本
    1. 将其命名为Login,并点击Finish
    2. 从脚本资源管理器中双击Private Object Map
    3. 确保 mail.yahoo.com site 网站(或者被测试应用)是打开的。
    4. 从 Private Object 图中,点击Test Object > Insert Object(s),如图2所示。

    图2. 插入一个测试对象
    插入一个测试对象
    1. 将指针图标工具从下面的对话框拖到你想映射的目标位置,如图3和图4所示。

    图3. 通过拖拽选择一个对象
    通过拖拽选择一个对象

    图4. 选择的对象
    选择的对象
    1. 点击Finish
    2. 你的Private Object Map窗口应该看起来如图5所示。

    图5. 已完成的 Private Object Map
    已完成的 Private Object Map
    1. 选择你最近添加的对象,点击右键并选择 Add to scrīpt AppObject.Login
    2. 对所有你想要添加到这个脚本的对象重复6-10的步骤。
    3. 点击File > Save并关闭它。你的脚本资源管理器应该看起来如图6所示。

    图6. Login的脚本资源管理器
    Login 的脚本资源管理器
    1. 类似地,你可以尽可能创建更多的脚本到你的项目中,并添加相关的对象。

    自动产生 AppObjects 代码

    一旦你将你的对象添加到你的对象地图中,就可以通过编写几行代码自动产生你的getter 方法。这些getter 方法将帮助你访问跨越或在项目中被添加的脚本中的对象。你将在AppObject文件夹中创建一个空的脚本,编写如列表1中所示的代码来自动产生getter方法

    1. 在AppObject文件夹中创建一个名叫getter 的空脚本文件。
    2. 创建列表1中的代码。

    列表1.自动生getter的代码
                    
    //IMPORT THESE 2 STATEMENTS AT THE TOP OF scrīpt
    import java.util.Vector; 
    import ibm.tools.ClassGenerator;
    //WRITE DOWN  THE BELOW CODE IN TESTMAIN FUNCTION
    public void testMain(Object[] args) 
    	{
    		Vector v = new Vector();
    		v.addElement (new AppObject.Login ());
    	//ADD ELEMENT FOR ALL THE scrīptS YOU HAVE IN YOUR AppObject
    		new ClassGenerator().updatescrīpts(v);
    	}				
    				

    1. 你的Getter脚本内容看起来应该如图7所示。

    图7. Getter 脚本
    Getter 脚本
    1. 选择scrīpt > Run来运行这个脚本。
    2. 运行一次以后,当你点击你的Login脚本时,它将查询你是否要装载这些变更。
    3. 点击Yes,你应该可以看到你的Login脚本已经有了Getter功能,如图8所示。

    图8. 用 Getter 脚本登陆系统的功能
    用 Getter 脚本登陆系统的功能

    步骤4. 创建任务

    任务是你可以编写最大限度重用和最复杂代码的位置。

    1. 首先在Tasks文件夹中创建一个脚本(跟前面的AppObject Folder操作一样)
    2. 选择Tasks文件夹,右键点击它并选择Add Empty scrīpt
    3. 指定详细的名称并点击Finish
    4. 将列表2中的代码插入到脚本中。

    列表2. 登陆任务
                    
    //DECLARE THE OBJECT OF THE scrīptS EXIST IN APPOBJECT 
    public AppObject.Login lgn = new AppObject.Login();
    ….
    ….
    public AppObject.Login lgn = new AppObject.Login();
    	public void AssignLoginInfo()
    	{
    		lgn.getText_login().setText("abc");
    		lgn.getText_passwd().setText("New1");
    	}
    
    public void testMain(Object[] args) 
    {
    }							
    				

    1. 你的脚本内容应当看起来如图9所示。

    图9. 修正脚本内容
    修正脚本内容
    1. 你可以在同一个脚本或者新的脚本中根据每个应用程序的需要随意增加各种功能。

    接下来,你将使这些功能实现自动化

    步骤5. 创建测试用例

    在测试用例中,你可以编写现有的步骤来完成这些行为,这将继承一些 Tasks 和 Appobject的属性特征。

    1. 首先在Tasks文件夹中创建一个脚本(跟前面的AppObject Folder操作一样)
    2. 选择Tasks文件夹,右键点击它并选择Add Empty scrīpt
    3. 指定详细的名称并点击Finish
    4. 将列表3中的代码插入到脚本中。

    列表3. 测试用例
                    
    //DECLARE THE OBJECT OF THE scrīptS EXIST IN TASKS 
    //OBJECT CREATION OF TASKS LOGINTASK scrīpt
    	public Tasks.LoginTask lt = new Tasks.LoginTask();
    ….
    ….
    public void testMain(Object[] args) 
    {
    	//INVOKING THE BROWSER
    	startBrowser("mail.yahoo.com");
    	//ASSIGNED THE USER NAME AND LOGIN INFO
    	lt.AssignLoginInfo();
    	//CLICKED ON LOGIN/SUBMIT BUTTON
    	lt.lgn.getButton_signInsubmit().click();
    	//FURTHER ACTION CAN BE WRITTEN ACCORDIUNLGY		
    }
    

    1. 你的脚本内容看起来应当如图10所示

    图10. 最后的脚本
    最后的脚本
    1. 现在运行这个脚本,打开浏览器,输入用户名和密码,然后登陆到Yahoo帐户
  • 45 questions about LR(转载)

    2006-12-27 14:54:24

    1. What is load testing? - Load testing is to test that if the application works fine with the loads that result from large number of simultaneous users, transactions and to determine weather it can handle peak usage periods.
    2. What is Performance testing? - Timing for both read and update transactions should be gathered to determine whether system functions are being performed in an acceptable timeframe. This should be done standalone and then in a multi user environment to determine the effect of multiple transactions on the timing of a single transaction.
    3. Did u use LoadRunner? What version? - Yes. Version 7.2.
    4. Explain the Load testing process? -
      Step 1: Planning the test. Here, we develop a clearly defined test plan to ensure the test scenarios we develop will accomplish load-testing objectives. Step 2: Creating Vusers. Here, we create Vuser scrīpts that contain tasks performed by each Vuser, tasks performed by Vusers as a whole, and tasks measured as transactions. Step 3: Creating the scenario. A scenario describes the events that occur during a testing session. It includes a list of machines, scrīpts, and Vusers that run during the scenario. We create scenarios using LoadRunner Controller. We can create manual scenarios as well as goal-oriented scenarios. In manual scenarios, we define the number of Vusers, the load generator machines, and percentage of Vusers to be assigned to each scrīpt. For web tests, we may create a goal-oriented scenario where we define the goal that our test has to achieve. LoadRunner automatically builds a scenario for us. Step 4: Running the scenario.
      We emulate load on the server by instructing multiple Vusers to perform tasks simultaneously. Before the testing, we set the scenario configuration and scheduling. We can run the entire scenario, Vuser groups, or individual Vusers. Step 5: Monitoring the scenario.
      We monitor scenario execution using the LoadRunner online runtime, transaction, system resource, Web resource, Web server resource, Web application server resource, database server resource, network delay, streaming media resource, firewall server resource, ERP server resource, and Java performance monitors. Step 6: Analyzing test results. During scenario execution, LoadRunner records the performance of the application under different loads. We use LoadRunner’s graphs and reports to analyze the application’s performance.
    5. When do you do load and performance Testing? - We perform load testing once we are done with interface (GUI) testing. Modern system architectures are large and complex. Whereas single user testing primarily on functionality and user interface of a system component, application testing focuses on performance and reliability of an entire system. For example, a typical application-testing scenario might depict 1000 users logging in simultaneously to a system. This gives rise to issues such as what is the response time of the system, does it crash, will it go with different software applications and platforms, can it hold so many hundreds and thousands of users, etc. This is when we set do load and performance testing.
    6. What are the components of LoadRunner? - The components of LoadRunner are The Virtual User Generator, Controller, and the Agent process, LoadRunner Analysis and Monitoring, LoadRunner Books Online.
    7. What Component of LoadRunner would you use to record a scrīpt? - The Virtual User Generator (VuGen) component is used to record a scrīpt. It enables you to develop Vuser scrīpts for a variety of application types and communication protocols.
    8. What Component of LoadRunner would you use to play Back the scrīpt in multi user mode? - The Controller component is used to playback the scrīpt in multi-user mode. This is done during a scenario run where a vuser scrīpt is executed by a number of vusers in a group.
    9. What is a rendezvous point? - You insert rendezvous points into Vuser scrīpts to emulate heavy user load on the server. Rendezvous points instruct Vusers to wait during test execution for multiple Vusers to arrive at a certain point, in order that they may simultaneously perform a task. For example, to emulate peak load on the bank server, you can insert a rendezvous point instructing 100 Vusers to deposit cash into their accounts at the same time.
    10. What is a scenario? - A scenario defines the events that occur during each testing session. For example, a scenario defines and controls the number of users to emulate, the actions to be performed, and the machines on which the virtual users run their emulations.
    11. Explain the recording mode for web Vuser scrīpt? - We use VuGen to develop a Vuser scrīpt by recording a user performing typical business processes on a client application. VuGen creates the scrīpt by recording the activity between the client and the server. For example, in web based applications, VuGen monitors the client end of the database and traces all the requests sent to, and received from, the database server. We use VuGen to: Monitor the communication between the application and the server; Generate the required function calls; and Insert the generated function calls into a Vuser scrīpt.
    12. Why do you create parameters? - Parameters are like scrīpt variables. They are used to vary input to the server and to emulate real users. Different sets of data are sent to the server each time the scrīpt is run. Better simulate the usage model for more accurate testing from the Controller; one scrīpt can emulate many different users on the system.
    13. What is correlation? Explain the difference between automatic correlation and manual correlation? - Correlation is used to obtain data which are unique for each run of the scrīpt and which are generated by nested queries. Correlation provides the value to avoid errors arising out of duplicate values and also optimizing the code (to avoid nested queries). Automatic correlation is where we set some rules for correlation. It can be application server specific. Here values are replaced by data which are created by these rules. In manual correlation, the value we want to correlate is scanned and create correlation is used to correlate.
    14. How do you find out where correlation is required? Give few examples from your projects? - Two ways: First we can scan for correlations, and see the list of values which can be correlated. From this we can pick a value to be correlated. Secondly, we can record two scrīpts and compare them. We can look up the difference file to see for the values which needed to be correlated.  In my project, there was a unique id developed for each customer, it was nothing but Insurance Number, it was generated automatically and it was sequential and this value was unique. I had to correlate this value, in order to avoid errors while running my scrīpt. I did using scan for correlation.
    15. Where do you set automatic correlation options? - Automatic correlation from web point of view can be set in recording options and correlation tab. Here we can enable correlation for the entire scrīpt and choose either issue online messages or offline actions, where we can define rules for that correlation. Automatic correlation for database can be done using show output window and scan for correlation and picking the correlate query tab and choose which query value we want to correlate. If we know the specific value to be correlated, we just do create correlation for the value and specify how the value to be created.
    16. What is a function to capture dynamic values in the web Vuser scrīpt? - Web_reg_save_param function saves dynamic data information to a parameter.
    17. When do you disable log in Virtual User Generator, When do you choose standard and extended logs? - Once we debug our scrīpt and verify that it is functional, we can enable logging for errors only. When we add a scrīpt to a scenario, logging is automatically disabled. Standard Log Option: When you select
      Standard log, it creates a standard log of functions and messages sent during scrīpt execution to use for debugging. Disable this option for large load testing scenarios. When you copy a scrīpt to a scenario, logging is automatically disabled Extended Log Option: Select
      extended log to create an extended log, including warnings and other messages. Disable this option for large load testing scenarios. When you copy a scrīpt to a scenario, logging is automatically disabled. We can specify which additional information should be added to the extended log using the Extended log options.
    18. How do you debug a LoadRunner scrīpt? - VuGen contains two options to help debug Vuser scrīpts-the Run Step by Step command and breakpoints. The Debug settings in the Options dialog box allow us to determine the extent of the trace to be performed during scenario execution. The debug information is written to the Output window. We can manually set the message class within your scrīpt using the lr_set_debug_message function. This is useful if we want to receive debug information about a small section of the scrīpt only.
    19. How do you write user defined functions in LR? Give me few functions you wrote in your previous project? - Before we create the User Defined functions we need to create the external
      library (DLL) with the function. We add this library to VuGen bin directory. Once the library is added then we assign user defined function as a parameter. The function should have the following format: __declspec (dllexport) char* <function name>(char*, char*)Examples of user defined functions are as follows:GetVersion, GetCurrentTime, GetPltform are some of the user defined functions used in my earlier project.
    20. What are the changes you can make in run-time settings? - The Run Time Settings that we make are: a) Pacing - It has iteration count. b) Log - Under this we have Disable Logging Standard Log and c) Extended Think Time - In think time we have two options like Ignore think time and Replay think time. d) General - Under general tab we can set the vusers as process or as multithreading and whether each step as a transaction.
    21. Where do you set Iteration for Vuser testing? - We set Iterations in the Run Time Settings of the VuGen. The navigation for this is Run time settings, Pacing tab, set number of iterations.
    22. How do you perform functional testing under load? - Functionality under load can be tested by running several Vusers concurrently. By increasing the amount of Vusers, we can determine how much load the server can sustain.
    23. What is Ramp up? How do you set this? - This option is used to gradually increase the amount of Vusers/load on the server. An initial value is set and a value to wait between intervals can be
      specified. To set Ramp Up, go to ‘Scenario Scheduling Options’
    24. What is the advantage of running the Vuser as thread? - VuGen provides the facility to use multithreading. This enables more Vusers to be run per
      generator. If the Vuser is run as a process, the same driver program is loaded into memory for each Vuser, thus taking up a large amount of memory. This limits the number of Vusers that can be run on a single
      generator. If the Vuser is run as a thread, only one instance of the driver program is loaded into memory for the given number of
      Vusers (say 100). Each thread shares the memory of the parent driver program, thus enabling more Vusers to be run per generator.
    25. If you want to stop the execution of your scrīpt on error, how do you do that? - The lr_abort function aborts the execution of a Vuser scrīpt. It instructs the Vuser to stop executing the Actions section, execute the vuser_end section and end the execution. This function is useful when you need to manually abort a scrīpt execution as a result of a specific error condition. When you end a scrīpt using this function, the Vuser is assigned the status "Stopped". For this to take effect, we have to first uncheck the “Continue on error” option in Run-Time Settings.  
    26. What is the relation between Response Time and Throughput? - The Throughput graph shows the amount of data in bytes that the Vusers received from the server in a second. When we compare this with the transaction response time, we will notice that as throughput decreased, the response time also decreased. Similarly, the peak throughput and highest response time would occur approximately at the same time.
    27. Explain the Configuration of your systems? - The configuration of our systems refers to that of the client machines on which we run the Vusers. The configuration of any client machine includes its hardware settings, memory, operating system, software applications, development tools, etc. This system component configuration should match with the overall system configuration that would include the network infrastructure, the web server, the database server, and any other components that go with this larger system so as to achieve the load testing objectives.
    28. How do you identify the performance bottlenecks? - Performance Bottlenecks can be detected by using monitors. These monitors might be application server monitors, web server monitors, database server monitors and network monitors. They help in finding out the troubled area in our scenario which causes increased response time. The measurements made are usually performance response time, throughput, hits/sec, network delay graphs, etc.
    29. If web server, database and Network are all fine where could be the problem? - The problem could be in the system itself or in the application server or in the code written for the application.
    30. How did you find web server related issues? - Using Web resource monitors we can find the performance of web servers. Using these monitors we can analyze throughput on the web server, number of hits per second that
      occurred during scenario, the number of http responses per second, the number of downloaded pages per second.
    31. How did you find database related issues? - By running “Database” monitor and help of “Data Resource Graph” we can find database related issues. E.g. You can specify the resource you want to measure on before running the controller and than you can see database related issues
    32. Explain all the web recording options?
    33. What is the difference between Overlay graph and Correlate graph? - Overlay Graph: It overlay the content of two graphs that shares a common x-axis. Left Y-axis on the merged graph show’s the current graph’s value & Right Y-axis show the value of Y-axis of the graph that was merged. Correlate Graph: Plot the Y-axis of two graphs against each other. The active graph’s Y-axis becomes X-axis of merged graph. Y-axis of the graph that was merged becomes merged graph’s Y-axis.
    34. How did you plan the Load? What are the Criteria? - Load test is planned to decide the number of users, what kind of machines we are going to use and from where they are run. It is based on 2 important documents, Task Distribution Diagram and Transaction profile. Task Distribution Diagram gives us the information on number of users for a particular transaction and the time of the load. The peak usage and off-usage are decided from this Diagram. Transaction profile gives us the information about the transactions name and their priority levels with regard to the scenario we are deciding.
    35. What does vuser_init action contain? - Vuser_init action contains procedures to login to a server.
    36. What does vuser_end action contain? - Vuser_end section contains log off procedures.  
    37. What is think time? How do you change the threshold? -   Think time is the time that a real user waits between actions. Example: When a user receives data from a server, the user may wait several seconds to review the data before responding. This delay is known as the think time. Changing the Threshold: Threshold level is the level below which the recorded think time will be ignored. The default value is five (5) seconds. We can change the think time threshold in the Recording options of the Vugen.
    38. What is the difference between standard log and extended log? - The standard log sends a subset of functions and messages sent during scrīpt execution to a log. The subset depends on the Vuser type Extended log sends a detailed scrīpt execution messages to the output log. This is mainly used during debugging when we want information about: Parameter substitution. Data returned by the server. Advanced trace.
    39. Explain the following functions: - lr_debug_message - The lr_debug_message function sends a debug message to the output log when the specified message class is set. lr_output_message - The lr_output_message function sends notifications to the Controller Output window and the Vuser log file. lr_error_message - The lr_error_message function sends an error message to the LoadRunner Output window. lrd_stmt - The lrd_stmt function associates a character string (usually a SQL statement) with a cursor. This function sets a SQL statement to be processed. lrd_fetch - The lrd_fetch function fetches the next row from the result set.
    40. Throughput -  If the throughput scales upward as time progresses and the number of Vusers increase, this indicates that the bandwidth is sufficient. If the graph were to remain relatively flat as the number of Vusers increased, it would
      be reasonable to conclude that the bandwidth is constraining the volume of
      data delivered. 
    1. Types of Goals in Goal-Oriented Scenario -  Load Runner provides you with five different types of goals in a goal oriented scenario:
    2. The number of concurrent Vusers
    • The number of hits per second
    • The number of transactions per second
    • The number of pages per minute
    • The transaction response time that you want your scenario
    1. Analysis Scenario (Bottlenecks): In Running Vuser graph correlated with the response time graph you can see that as the number of Vusers increases, the average response time of the check itinerary transaction very gradually increases. In other words, the average response time steadily increases as the load
      increases. At 56 Vusers, there is a sudden, sharp increase in the average response
      time. We say that the test broke the server. That is the mean time before failure (MTBF). The response time clearly began to degrade when there were more than 56 Vusers running simultaneously.
    2. What is correlation? Explain the difference between automatic correlation and manual correlation? - Correlation is used to obtain data which are unique for each run of the scrīpt and which are generated by nested queries. Correlation provides the value to avoid errors arising out of duplicate values and also optimizing the code (to avoid nested queries). Automatic correlation is where we set some rules for correlation. It can be application server specific. Here values are replaced by data which are created by these rules. In manual correlation, the value we want to correlate is scanned and create correlation is used to correlate.
    3. Where do you set automatic correlation options? - Automatic correlation from web point of view, can be set in recording options and correlation tab. Here we can enable correlation for the entire scrīpt and choose either issue online messages or offline actions, where we can define rules for that correlation.  Automatic correlation for database, can be done using show output window and scan for correlation and picking the correlate query tab and choose which query value we want to correlate. If we know the specific value to be correlated, we just do create correlation for the value and specify how the value to be created.
    4. What is a function to capture dynamic values in the web vuser scrīpt? - Web_reg_save_param function saves dynamic data information to a parameter.

数据统计

  • 访问量: 2161
  • 日志数: 4
  • 建立时间: 2006-12-26
  • 更新时间: 2008-12-19

RSS订阅

Open Toolbar