Pages

Tuesday, April 26, 2011

A good tester

knows different testing strategies and methodologies;
knows how to use tools.(when, where, how);
nice to know programming;
good communication/documentation skills;
personality: patient, practical, detail oriented,team player;
self-motivated to learn new technology, develop new skills.

Monday, April 25, 2011

性能测试(并发负载压力)测试分析(转载)

分析原则:
• 具体问题具体分析(这是由于不同的应用系统,不同的测试目的,不同的性能关注点)
• 查找瓶颈时按以下顺序,由易到难。
服务器硬件瓶颈
网络瓶颈(对局域网,可以不考虑)
服务器操作系统瓶颈(参数配置)
中间件瓶颈(参数配置,数据库, web 服务器等)
应用瓶颈( SQL 语句、数据库设计、业务逻辑、算法等)
注:以上过程并不是每个分析中都需要的,要根据测试目的和要求来确定分析的深度。对一些要求低的,我们分析到应用系统在将来大的负载压力(并发用户数、数据量)下,系统的硬件瓶颈在哪儿就够了。

• 分段排除法 很有效

分析的信息来源:
• 1 根据场景运行过程中的错误提示信息
• 2 根据测试结果收集到的监控指标数据


一.错误提示分析
分析实例:

1 • Error: Failed to connect to server “ 10.10.10 .30:8080 ″ : [10060] Connection

• Error: timed out Error: Server “ 10.10.10 .30 ″ has shut down the connection prematurely

分析:
• A 、应用服务死掉。
(小用户时:程序上的问题。程序上处理数据库的问题)

• B 、应用服务没有死
(应用服务参数设置问题)
例:在许多客户端连接 Weblogic 应用服务器被拒绝,而在服务器端没有错误显示,则有可能是 Weblogic 中的 server 元素的 AcceptBacklog 属性值设得过低。如果连接时收到 connection refused 消息,说明应提高该值,每次增加 25 %

• C 、数据库的连接
(1 、在应用服务的性能参数可能太小了 2 、数据库启动的最大连接数(跟硬件的内存有关) )

2 Error: Page download timeout (120 seconds) has expired

分析:可能是以下原因造成
• A 、应用服务参数设置太大导致服务器的瓶颈
• B 、页面中图片太多
• C 、在程序处理表的时候检查字段太大多

二.监控指标数据分析
1 .最大并发用户数:
应用系统在当前环境(硬件环境、网络环境、软件环境(参数配置))下能承受的最大并发用户数。
在方案运行中,如果出现了大于 3 个用户的业务操作失败,或出现了服务器 shutdown 的情况,则说明在当前环境下,系统承受不了当前并发用户的负载压力,那么最大并发用户数就是前一个没有出现这种现象的并发用户数。
如果测得的最大并发用户数到达了性能要求,且各服务器资源情况良好,业务操作响应时间也达到了用户要求,那么 OK 。否则,再根据各服务器的资源情况和业务操作响应时间进一步分析原因所在。

2 .业务操作响应时间:
• 分析方案运行情况应从平均事务响应时间图和事务性能摘要图开始。使用“事务性能摘要”图,可以确定在方案执行期间响应时间过长的事务。
• 细分事务并分析每个页面组件的性能。查看过长的事务响应时间是由哪些页面组件引起的?问题是否与网络或服务器有关?
• 如果服务器耗时过长,请使用相应的服务器图确定有问题的服务器度量并查明服务器性能下降的原因。如果网络耗时过长,请使用“网络监视器”图确定导致性能瓶颈的网络问题

3 .服务器资源监控指标:
内存:
1 UNIX 资源监控中指标内存页交换速率( Paging rate ),如果该值偶尔走高,表明当时有线程竞争内存。如果持续很高,则内存可能是瓶颈。也可能是内存访问命中率低。

2 Windows 资源监控中,如果 Process\Private Bytes 计数器和 Process\Working Set 计数器的值在长时间内持续升高,同时 Memory\Available bytes 计数器的值持续降低,则很可能存在内存泄漏。

内存资源成为系统性能的瓶颈的征兆 :

很高的换页率 (high pageout rate);
进程进入不活动状态 ;
交换区所有磁盘的活动次数可高 ;
可高的全局系统 CPU 利用率 ;
内存不够出错 (out of memory errors)

处理器:

1 UNIX 资源监控( Windows 操作系统同理)中指标 CPU 占用率( CPU utilization ),如果该值持续超过 95% ,表明瓶颈是 CPU 。可以考虑增加一个处理器或换一个更快的处理器。如果服务器专用于 SQL Server, 可接受的最大上限是 80-85%
合理使用的范围在 60% 至 70% 。
2 Windows 资源监控中,如果 System\Processor Queue Length 大于 2 ,而处理器利用率( Processor Time )一直很低,则存在着处理器阻塞。


CPU 资源成为系统性能的瓶颈的征兆 :
很慢的响应时间 (slow response time)
CPU 空闲时间为零 (zero percent idle CPU)
过高的用户占用 CPU 时间 (high percent user CPU)
过高的系统占用 CPU 时间 (high percent system CPU)
长时间的有很长的运行进程队列 (large run queue size sustained over time)

磁盘 I/O :

1 UNIX 资源监控( Windows 操作系统同理)中指标磁盘交换率( Disk rate ),如果该参数值一直很高,表明 I/O 有问题。可考虑更换更快的硬盘系统。
2 Windows 资源监控中,如果 Disk Time 和 Avg.Disk Queue Length 的值很高,而 Page Reads/sec 页面读取操作速率很低,则可能存在磁盘瓶径。

I/O 资源成为系统性能的瓶颈的征兆 :
过高的磁盘利用率 (high disk utilization)
太长的磁盘等待队列 (large disk queue length)
等待磁盘 I/O 的时间所占的百分率太高 (large percentage of time waiting for disk I/O)
太高的物理 I/O 速率 :large physical I/O rate(not sufficient in itself)
过低的缓存命中率 (low buffer cache hit ratio(not sufficient in itself))
太长的运行进程队列,但 CPU 却空闲 (large run queue with idle CPU)

4 .数据库服务器:

SQL Server 数据库:

1 SQLServer 资源监控中指标缓存点击率( Cache Hit Ratio ),该值越高越好。如果持续低于 80% ,应考虑增加内存。
2 如果 Full Scans/sec (全表扫描 / 秒)计数器显示的值比 1 或 2 高,则应分析你的查询以确定是否确实需要全表扫描,以及 SQL 查询是否可以被优化。
3 Number of Deadlocks/sec( 死锁的数量 / 秒 ) :死锁对应用程序的可伸缩性非常有害,并且会导致恶劣的用户体验。该计数器的值必须为 0 。
4 Lock Requests/sec( 锁请求 / 秒 ) ,通过优化查询来减少读取次数,可以减少该计数器的值。

Oracle 数据库:

1 如果自由内存接近于 0 而且库快存或数据字典快存的命中率小于 0.90 ,那么需要增加 SHARED_POOL_SIZE 的大小。
快存(共享 SQL 区)和数据字典快存的命中率:
select(sum(pins-reloads))/sum(pins) from v$librarycache;
select(sum(gets-getmisses))/sum(gets) from v$rowcache;
自由内存: select * from v$sgastat where name= ’ free memory ’ ;

2 如果数据的缓存命中率小于 0.90 ,那么需要加大 DB_BLOCK_BUFFERS 参数的值(单位:块)。

缓冲区高速缓存命中率:
select name,value from v$sysstat where name in (’db block gets’,
‘ consistent gets’,'physical reads’) ;
Hit Ratio = 1-(physical reads / ( db block gets + consistent gets))

3 如果日志缓冲区申请的值较大,则应加大 LOG_BUFFER 参数的值。

日志缓冲区的申请情况 :
select name,value from v$sysstat where name = ‘redo log space requests’ ;

4 如果内存排序命中率小于 0.95 ,则应加大 SORT_AREA_SIZE 以避免磁盘排序 。

内存排序命中率 :
select round((100*b.value)/decode((a.value+b.value), 0, 1, (a.value+b.value)), 2)from v$sysstat a, v$sysstat b where a.name=’sorts (disk)’ and b.name=’sorts (memory)’

注:上述 SQL Server 和 Oracle 数据库分析,只是一些简单、基本的分析,特别是 Oracle 数据库的分析和优化,是一门专门的技术,进一步的分析可查相关资料。

ETL Testing

ETL basically stands for Extract Transform Load - which simply implies the process where you extract data from Source Tables, transform them in to the desired format based on certain rules and finally load them onto Target tables. There are numerous tools that help you with ETL process - Informatica, Control-M being a few notable ones.

So ETL Testing implies - Testing this entire process using a tool or at table level with the help of test cases and Rules Mapping document.

In ETL Testing, the following are prima facie validated -
1) Data File loads from Source system on to Source Tables.
2) The ETL Job that is designed to extract data from Source tables and then move them to staging tables. (Transform process)
3) Data validation within the Staging tables to check all Mapping Rules / Transformation Rules are followed.
4) Data Validation within Target tables to ensure data is present in required format and there is no data loss from Source to Target tables.

check out Service Oriented Architecture (SOA) testing. This will help you better understand how Informatica works and how you should test them.
--------------------------------------------
ETL stands for extract, transform, and load. It can consolidate the scattered data for any organization while working with different departments. It can very well handle the data coming from different departments.
For example, a health insurance organization might have information on a customer in
several departments and each department might have that customer's information listed in a different way. The membership department might list the customer by name, whereas the claims department might list the customer by number. ETL can bundle all this data and consolidate it into a uniform presentation, such as for storing in a database or data warehouse.
ETL can transform not only data from different departments but also data from different sources altogether. For example, any organization is running its business on different environments like SAP and Oracle Apps for their businesses. If the higher management wants to take discussion on their business, they want to make the data integrated and used it for their reporting purposes. ETL can take these two source system data and make it integrated in to single format and load it into the tables.

Generally the normal testing steps are:
• Requirements Analysis
• Testing Methodologies
• Test Plans and approach
• Test Cases
• Test Execution
• Verification and Validation
• Reviews and Walkthroughs

The main difference in testing a ETL is that we basically involve the SQL queries in our test case documents. It is vital to test both the initial loads of the Data
Warehouse from the source i.e. when it gets extracted and then updating it on the target table i.e. the loading step. In specific cases, where trouble shooting is required, we verify intermediate steps as well.

A defect or bug detection can be appreciated if and only if it is detected early and is fixed at the right time without leading to a high cost. So to achieve it, it is very important to set some basic testing rules. They are:
• No Data losses
• Correct transformation rules
• Data validation
• Regression Testing
• Oneshot/ retrospective testing
• Prospective testing
• View testing
• Sampling
• Post implementation

Wednesday, April 20, 2011

电子邮箱相关技术(POP3/SMTP/IMAP/SSL)

POP3服务器主管邮件的收取,SMTP服务器主管邮件的发送。 每一个电子邮件系统都必须同时拥有这两类服务器才能完成信件的收发。


一、POP3

  POP3是Post Office Protocol 3的简称,即邮局协议的第3个版本,它规定怎样将个人计算机连接到Internet的邮件服务器和下载电子邮件的电子协议。主要功能是用在传送电子邮件,当我们寄信给另外一个人时,对方当时多半不会在线上,所以邮件服务器必须为收信者保存这封信,直到收信者来检查这封信件。当收信人收信的时候,必须通过POP通讯协定,才能取得邮件。它是因特网电子邮件的第一个离线协议标准,POP3允许用户从服务器上把邮件存储到本地主机(即自己的计算机)上,同时删除保存在邮件服务器上的邮件,而POP3服务器则是遵循POP3协议的接收邮件服务器,用来接收电子邮件的。

二、SMTP

  SMTP(Simple Mail Transfer Protocol)简易邮件传输通讯协议

SMTP是互联网上的一种通讯协议,主要功能是用在传送电子邮件,当我们通过电子邮件程序,寄E-mil给另外一个人时,必须通过SMTP通讯协议,将邮件送到对方的邮件服务器上,等到对方上网的时候,就可以收到你所寄的信。

  SMTP 认证,简单地说就是要求必须在提供了账户名和密码之后才可以登录 SMTP 服务器,这就使得那些垃圾邮件的散播者无可乘之机。增加 SMTP 认证的目的是为了使用户避免受到垃圾邮件的侵扰。

  其实简单的说,POP服务器是用来收信的,而且每个E_mail地址一般只有一个。如果你要同时收取多个邮箱的信件,就必须挨个设置每个邮箱的POP3服务器地址。你别告诉我找不到,告诉你一个小窍门吧:在你申请了免费信箱之后,仔细看看它的帮助文件,一般都能找到。至于SMTP服务器,可以理解为就是用来寄信的,而且大多数SMTP服务器也是免费的,也就是说,不管你有无E-mail信箱,只要想寄信,随便填上一个SMTP服务器,就可以寄信了。如果你用Outlook Express或者其它邮件程序发信,又同时拥有多个免费邮箱,不必设置多个SMTP服务器,只要选择一个填上就行了,比如新浪邮件提供的服务器就是:smtp.sina.com.cn。

三、IMAP

  IMAP全称是Internet Mail Access Protocol,即交互式邮件存取协议,它是跟POP3类似邮件访问标准协议之一。不同的是,开启了IMAP后,您在电子邮件客户端收取的邮件仍然保留在服务器上,同时在客户端上的操作都会反馈到服务器上,如:删除邮件,标记已读等,服务器上的邮件也会做相应的动作。所以无论从浏览器登录邮箱或者客户端软件登录邮箱,看到的邮件以及状态都是一致的。

四、SSL
  SSL的英文全称是 "Secure Sockets Layer” ,中文名为 “ 安全套接层协议层 ”,它是网景( Netscape )公司提出的基于 WEB 应用的安全协议。 SSL 协议指定了一种在应用程序协议(如 HTTP 、 Telenet 、 NMTP 和 FTP 等)和 TCP/IP 协议之间提供数据安全性分层的机制,它为 TCP/IP 连接提供数据加密、服务器认证、消息完整性以及可选的客户机认证。
SSL VPN 客户端的应用是基于标准 Web 浏览器内置的加密套件与服务器协议出相应的加密方法,即经过授权用户只要能上网就能够通过浏览器接入服务器建立 SSL 安全隧道。
SSL安全服务原来是仅用于网易收费邮箱的。现在126、163都应用了
网易免费邮箱的SSL安全服务使用起来非常简单,只需在邮箱web页面(例如126免费邮www.126.com)的常规登陆入口处选择“安全”模式既可。SSL是一种成熟、可靠的邮箱安全技术,能够最有效地保护用户的机密信息,彻底杜绝从浏览器到服务器之间密码被非法窃取和篡改的现象。

五、IMAP与POP有什么不同?

  POP3协议允许电子邮件客户端下载服务器上的邮件,但是在客户端的操作(如移动邮件、标记已读等),不会反馈到服务器上,比如通过客户端收取了邮箱中的3封邮件并移动到其他文件夹,邮箱服务器上的这些邮件是没有同时被移动的 。而IMAP提供webmail 与电子邮件客户端之间的双向通信,客户端的操作都会反馈到服务器上,对邮件进行的操作,服务器上的邮件也会做相应的动作。
  同时,IMAP像POP那样提供了方便的邮件下载服务,让用户能进行离线阅读。IMAP提供的摘要浏览功能可以让你在阅读完所有的邮件到达时间、主题、发件人、大小等信息后才作出是否下载的决定。此外,IMAP 更好地支持了从多个不同设备中随时访问新邮件。

  总之,IMAP 整体上为用户带来更为便捷和可靠的体验。POP 更易丢失邮件或多次下载相同的邮件,但 IMAP 通过邮件客户端与webmail 之间的双向同步功能很好地避免了这些问题。

java

学习JAVA一定要先把JAVA的几个基本组成元素学好。

  1、数据类型:JAVA是一种强类型语言,各种类型不会自动转换,使用前必须先定义。

  2、方法:方法相当于定义一个“宏”、一个“函数”, 方法的定义格式为:“说明符 修饰符 返回值 方法名(参数){方法体}。”在学习方法的时候要注意“说明符、”修饰符“、”返回值“这三样东西。

  3、类:在JAVA中最经常听到词,也是最麻烦的东西。

  4、变量常量:JAVA的常量名一般用全大写字母表示,并且为了节省内存,一般定义为静态(JAVA程序中的名字我们经常有个默认的规则,类名所有单词第一个字母大写,方法名第二个单词开始第一个字母大写,变量名小写,这样我们一看程序就非常清楚了,从小养成良好的习惯嘛,呵呵)。学习变量的时候要注意两个特殊的东西”this“ 和”super“。同时我们就要学习什么叫”覆盖“、”重载“。

  5、控制流:所有的编程语言的控制语句无非就是几个if else for while do switch。

  6、接口:一个抽象的东西,接口可以多继承,解决了类只能单继承的问题。

  7、线程:线程是个比较复杂的东西,例如一个赛马程序有七匹马赛跑,就有七个线程,看起来好象是同时在跑,其实是计算机分配不同的时间段让七个线程运行。我们初学者的程序可能还用不上。

  到这里为止,JAVA的基本概念我们有一定的了解了,我们就开始研究JAVA的类了。

  JAVA的核心API(也就是SUN公司已经为我们写好的类)有以下几种。(还有其他很多的扩充类)

  Java.lang java.io java.util java.net java.awt java.applet java.sql java.text

  每个类有很多方法,每个对象的类型不同,可以使用的方法也不同,我们最好有一本类库在手中,可以随时查阅,如果您的英语好,也可以上SUN公司的网站或使用JBUILDER的帮助文档。

  谁都不可能一下子记住这么多类的用法,而且也并不是所有的类对我们的程序都有用,我们当然是选择我们需要的类进行学习。

  一般程序都逃不过字符串操作、文件操作、数据库操作,所以java.lang java.io java.sql这几个类我们必须要看。

Tuesday, April 19, 2011

Team Player

It takes more than just saying you’re a “team player” on your resume. To be a successful team player, you need to consider and pay attention to the following characteristics:

Responsibility

Not only can you count on a team player to get his share of the work done, you know that if you ask him to do something or be somewhere, it will be handled professionally and on time.

Flexibility

A team player can easily handle changing conditions in the workplace. He knows how to change gears easily, adapting to the situation at hand without complaining.

Commitment

A true team player has a strong desire to better the team in words and actions. He shows he is dedicated through consistent good effort and a willingness to step forward.

Problem solving

Teams are often formed to resolve issues that arise. A team player contributes to solutions and will also be able to handle any conflicts that may inherently arise from working with others.

Respectfulness

Team players treat others with respect and know how to appropriately get the job done. They support other team members and compliment and acknowledge the contribution of others.

Cooperation

A team player is always willing to pitch in, whether it is their direct responsibility or not. A team player keeps an eye on the bottom line, which is getting the job done. He gladly accepts requests for assistance, often taking the initiative to help out.

Monday, April 18, 2011

Equivalence Partitioning/Boundary Value Analysis

There are various techniques in developing test cases for black box testing. I will be explaining two of the most common techniques, Equivalence Partitioning and BVA (Boundary Value Analysis)

Equivalence Partitioning
Equivalence partitioning is a black-box testing method that divides the input domain of a program into classes of data from which test cases can be derived. Test case design for equivalence partitioning is based on an evaluation of equivalence classes for an input condition. An equivalence class represents a set of valid or invalid states for input conditions. Typically, an input condition is either a specific numeric value, a range of values, a set of related values, or a boolean condition. Equivalence classes may be defined according to the following guidelines:

If an input condition specifies a range, one valid and two invalid equivalence classes are defined.
If an input condition requires a specific value, one valid and two invalid equivalence classes are defined.
If an input condition specifies a member of a set, one valid and one invalid equivalence class are defined.
If an input condition is boolean, one valid and one invalid class are defined.
As an example, consider data maintained as part of an automated banking application.

The user can access the bank using a personal computer, provide a six-digit password, and follow with a series of typed commands that trigger various banking functions. During the log-on sequence, the software supplied for the banking application accepts data in the form:

area code—blank or three-digit number
prefix—three-digit number not beginning with 0 or 1
suffix—four-digit number
password—six digit alphanumeric string
commands—check, deposit, bill pay, and the like
The input conditions associated with each data element for the banking application can be specified as area code:

Input condition, Boolean—the area code may or may not be present.
Input condition, range—values defined between 200 and 999, with specific exceptions.
prefix: Input condition, range—specified value >200
Input condition, value—four-digit length
password: Input condition, Boolean—a password may or may not be present.
Input condition, value—six-character string.
command: Input condition, set—containing commands noted previously.
Applying the guidelines for the derivation of equivalence classes, test cases for each input domain data item can be developed and executed. Test cases are selected so that the largest number of attributes of an equivalence class are exercised at once.

Boundary Value Analysis
BVA extends equivalence partitioning by focusing on data at the “edges” of an equivalence class.

For reasons that are not completely clear, a greater number of errors tends to occur at the boundaries of the input domain rather than in the "center". It is for this reason that boundary value analysis (BVA) has been developed as a testing technique. Boundary value analysis leads to a selection of test cases that exercise bounding values.

Boundary value analysis is a test case design technique that complements equivalence partitioning. Rather than selecting any element of an equivalence class, BVA leads to the selection of test cases at the "edges" of the class. Rather than focusing solely on input conditions, BVA derives test cases from the output domain as well.

Guidelines for BVA are similar in many respects to those provided for equivalence partitioning:

If an input condition specifies a range bounded by values a and b, test cases should be designed with values a and b and values just above and just below a and b.
If an input condition specifies a number of values, test cases should be developed that exercise the minimum and maximum numbers. Values just above and below minimum and maximum are also tested.
Apply guidelines 1 and 2 to output conditions. For example, assume that a temperature vs. pressure table is required as output from an engineering analysis program. Test cases should be designed to create an output report that produces the maximum (and minimum) allowable number of table entries.
If internal program data structures have prescribed boundaries (e.g., an array has a defined limit of 100 entries), be certain to design a test case to exercise the data structure at its boundary.
Most software engineers intuitively perform BVA to some degree. By applying these guidelines, boundary testing will be more complete, thereby having a higher likelihood for error detection.

Thursday, April 14, 2011

QTP如何启动应用程序(转)

2008-12-17 14:35:17

qtp提供了很多自动启动应用程序的办法,方法如下:
1)SystemUtil.Run 允许启动新的进程
格式:SystemUtil.Run file, [params], [dir], [op], [mode]
下面代码利用SystemUtil对象如何启动进程。
'启动IE

SystemUtil.Run "iexplore.exe"
SystemUtil.Run "iexplore.exe", "http://www.51testing.com/?72" '打开pcl blog
SystemUtil.Run "iexplore.exe", "http://www.knowledgeinbox.com", , , 3


'打开电影播放器
SystemUtil.Run "mplayerc.exe E:\movie\[2007.12.16]尖峰时刻3[2007成龙动作](帝国出品)\影视帝国(bbs.cnxp.com).尖峰时刻3.Rush.Hour.3.2007.DVDRip.cd1.rmvb /play"


2)InvokeApplication 启动应用程序
格式:InvokeApplication(Command [,StartIn])

例子:
'启动ie
InvokeApplication "IEXPLORE.EXE"
'启动计算器
InvokeApplication "calc.exe"

3) COM - Wsh
利用Wsh对象进行启动
例子:

Dim oShell
set ōShell= CreateObject ("Wscrīpt.shell")
oShell.Run "IEXPLORE.EXE"
Set ōShell = Nothing


4)Qtp自动启动应用程序
Qtp打开 Automation-〉Record and Run Settings 下进行设置

5)录制启动过程

Dialog("运行").WinEdit("打开(O):").Set "calc"
Dialog("运行").WinButton("确定").Click

查看(65) 评论(0) 收藏 分享 管理
自动化测试框架指南(转载)
2008-09-09 10:31:22

这是我以前写的一篇文章,用于整理自己对自动化测试的理解。当时写这个文章的目的,是因为刚刚掌握QTP,又使用自动化测试参与公司一个大项目的测试,结果发现原来掌握QTP距离自动化测试还有很遥远的路要走,原来一直以为掌握了QTP的脚本编写、可以写出所有的测试方法脚本则自动化测试就可以大功告成了。但是现实是残酷的,实际和自己所想的相差太远了——实际的情况是需求变化快,甚至有段时间开发还没有需求变化快,自动化测试脚本的维护工作量就可想而知了。

因此我当时就咨询了一下其他的测试同行,他们都认为测试代码复用是很重要的问题,要搭建一个好的测试框架,这就是我当时写这篇文章的目的。

但是在写了这篇文章后,因为工作原因没有用实践去验证文章里的思想,直到今天才有时间来温习以前的教训。今天来按实际来做时,发现了一个问题——用什么方式来划分test level service function 的颗粒呢?
打个比方来说,我要写一个测试函数,实现以下功能:我要测试的是登录一个系统,打开一个页面,然后新建一条记录。
因为还有其他的测试函数,肯定与这个函数有相同的代码部分,比如登录就是显而易见,但是还有一些代码肯定也是重复,而且是隐藏的,那么用什么方法把它们挖掘出来,细分的原则是什么?我实在想不清楚,需要大家的指点

文章里的一些内容取自别人的帖子或与同行的交流,所以只能算是半原创

自动化测试框架指南

以下只是测试框架的一点设想,需要以后修改;
这套方案的最终结果是实现测试自动化,但是因为目前人力、实力有限,只能逐步完善设想中的功能;最终的目的是要实现define the driver——定义驱动测试。
本文的自动化测试以MI公司的QuickTest professional 为例
1定义:
 Services function :业务函数
 TestCase(测试用例):是能够从头至尾独立执行的最小测试单元
 测试框架的设想

1.1Services Function 的分类及分类原则
Service Function的颗粒大小需求不一,靠自己来掌握,总之应该是尽量少的Service Function满足所有Case Function的需要
 Common level¬——所有项目测试都可以使用的函数,比如验证小数精度、写测试结果到报告等等。
Common level是公用的函数库,不需要经常修改,因此可以编成DLL文件,供所有的测试脚本使用。
使用语法可以这样:
‘------------------------------------
Set ōbject=createobject(“”)
Call object.funciton “”
‘------------------------------------

 High level¬——各项目专用的测试用例,是为专门的测试项目而设置的,但是这些Services Function不能单独作测试,必须配合更高一级的Test level才能使用
 Test level¬¬——Test level可以这样理解:是对某一个用户来说,为了完成某项工作和业务,时间从头至尾相对连续的一组操作。
 Test level并不是测试用例,但是它的颗粒大小却决定了其复用程度,因此需要仔细分析每个TestCase的业务逻辑,将相同的Test Level services function 总结出来。
 Test level的组成:
Function
Step ‘测试所要进行的操作
Validation ‘验证测试的结果
Return result ‘返回测试的结果,validation的验证结果也应该通过这一部分的函数写入到result report中
End function

1.2 Test case 和Test suite
 Test Case:测试用例。可以这样理解:是一组人为了完成某项工作和业务,时间从头至尾相对连续的一组操作
 Test suite: 是一个相同工作性质的工作部门人员,为了完成某项工作和业务,时间从头至尾相对连续的一组操作。
 Test case和Test suite的意义:
1、大量的Case,肯定是分模块存放的。否则就难以查询和维护、修改。
2、Test Case和Test level \high level service function的互相调用关系可以通过insight sources这个工具来查询。
3、Suite相当于一个Case模块,里面包含很多个Case;比如测试用户管理的,都放在一个Suite里,测试设备管理的,放在另一个suite里。
1.3TestCase的分类原则
 一般复杂Case,要牵扯到好多个模块的功能的,但是要看它的主要测试点是什么,然后按这个测试点所属模块,来确定这个Case归属哪个模块的。
 有依赖关系的Case,是合并成一个Case,还是保留独立?运行起来有依赖关系,倾向于合并成一个Case,合并的好处是运行方便,但是出错时要再区分是那个小Case的错误;分开的话,就相反,运行不方便,但出错时比较明确哪个错了。
 如果A是建10万个用户,要花1小时的时间,那你还会放在一块嘛,肯定是倾向分开成小Case,不然B出错了,你还得再重头跑ABCD,测试人员会气死的!所以运行麻烦、容易出错、时间较长的小case,还是保持独立,只要跟测试人员写好说明文档,让他们知道正确的运行方法,就可以了
 如果合成一个case,我应该把它放到哪个suite里呢 因为它横跨了几个页面,都是测试点,不好划分啊。放在那个Suite里啊,那都可以啊,或者你想独立一个suite也可以啊,无所谓的,只要你运行结果有正确记录,不会漏掉丢失就可以了。
 测试环境可以通过重新导入数据来恢复,这样就可以将一部分运行时间长、但是又有依赖关系的Test case分离出来,避免总是要从开头进行测试。
 一个Test suite里的用到的lib和OR都是相同的。




1.4测试用例和Services Function命名规则
类型 名称
Test case 项目名_TC_name
test level services function 项目名_TL_name
high level services function 项目名_HL_name
common level services function CL_name(不应包括项目名,因为此类函数是公用的)
2工作方式
并非所有的测试用例都可以用自动化来完成,因此需要对用例进行挑选,选择合适的用例作为自动化测试用例。记住!自动化测试的成本是巨大的,一般来说,一个脚本运行6~7次才算收回成本,因此不可寄予自动化测试过高期望。
2.1选择自动化测试用例
2.1.1不适合自动化测试用例的情况
 定制型项目(一次性的)。为客户定制的项目,维护期由客户方承担的,甚至采用的开发语言、运行环境也是客户特别要求的,即公司在这方面的测试积累就少,这样的项目不适合作自动化测试。
 项目周期很短的项目。项目周期很短,测试周期很短,就不值得花精力去投资自动化测试,好不容易建立起的测试脚本,不能得到重复的利用是不现实的。
 业务规则复杂的对象。业务规则复杂的对象,有很多的逻辑关系、运算关系,工具就很难测试。
 美观、声音、易用性测试。人的感观方面的:界面的美观、声音的体验、易用性的测试,也只有人来测试。
 测试很少运行。测试很少运行,对自动化测试就是一种浪费。自动化测试就是让它不厌其烦的、反反复复的运行才有效率。
 软件不稳定。软件不稳定,则会由于这些不稳定因素导致自动化测试失败。只有当软件达到相对的稳定,没有界面性严重错误和中断错误才能开始自动化测试。
 涉及物理交互。工具很难完成与物理设备的交互,比如刷卡的测试等。
2.1.2适合自动化测试的情况
自动化测试之所以能在很多大公司实施起来,就是有它适合自动化测试的特点和高的投资回报率。
 产品型项目。产品型的项目,每个项目只改进少量的功能,但每个项目必须反反复复的测试那些没有改动过的功能。这部分测试完全可以让自动化测试来承担, 同时可以把新加入的功能的测试也慢慢地加入到自动化测试当中。
 增量式开发、持续集成项目。由于这种开发模式是频繁的发布新版本进行测试,也就需要频繁的自动化测试,以便把人从中解脱出来测试新的功能。
 能够自动编译、自动发布的系统。要能够完全实现自动化测试,必须具有能够自动化编译,自动化发布系统进行测试的功能。 当然,不能达到这个要求也可以在手工干预的情况下进行自动化测试。
 回归测试。回归测试是自动化测试的强项,它能够很好的验证你是否引入了新的缺陷,老的缺陷是否修改过来了。在某种程度上可以把自动化测试工具叫做回归测试工具。
 多次重复、机械性动作,将烦琐的任务转化为自动化测试。自动化测试最适用于多次重复、机械性动作,这样的测试对它来说从不会失败。比如要向系统输入大量的相似数据来测试压力和报表。
 需要频繁运行测试。在一个项目中需要频繁的运行测试,测试周期按天算,就能最大限度的利用测试脚本,提高工作效率。
2.2编写Test case和Test level
分析Test Case的业务,将Test Level services function 的颗粒从Test Case中识别出来,尽量做到用少的Service function来实现测试业务。
2.3搭建测试框架
依据测试框架,在下一节中提到。依次填入测试框架的内容。
2.4执行测试并记录bug
这时就可以开始执行测试。测试结果应该自动被记录在测试报告中,而不应该一遇到BUG就停止——除非必须停止。这里注意以下几点
 测试报告功能应该在Common level中实现,这样所有的测试都可以共用。
 测试框架应该具有一定的判断功能,一旦某个测试失败。测试框架可以决定停止测试,或者转入不受影响的新测试用例,Test suite分类也应该注意这一点,因为同一个Test suite一般来说是互相影响的。
 测试框架可以具有某种还原测试环境的功能——即测试结束清理的功能,这样就可以自动恢复到不受影响的测试环境中。
2.5维护测试脚本
这是一项工作量很大的工作。维护脚本的难度很大程度上与团队活动有关,相关信息参考第4节。
3测试框架的构想
3.1Test Driver
测试框架的核心叫Test driver,它具有以下一些东西
 全局参数。
 所要测试的用例集,也许叫Test suite集更合适;包括测试所要用到的参数。
 对于用例的描述。
 lib and tsr。
 能够判断测试结果,并且决定是否调用其它的测试用例,或者停止测试。
 自动生成测试报告。以及需要输出的路径。
 每个测试脚本的初始设置路径
4团队开展自动化测试要点
单人自动化测试与团队开展自动化测试有很大不同,因为不同的对象名、不同的函数会造成每个人的测试脚本不同,并难以合并成一个完整、统一的脚本。为了解决这个问题,应该注意以下几点:
 团队成员在编写脚本时应该多使用对象库,尽量少使用描述性编程。
 统一对象名称,规定网页元素对象命名的统一规定,这样才可能在合并对象库时统一。
 统一函数命名规定。
 统一函数书写格式。
 统一对同一类型操作的处理方式——应该定期举行会议,沟通各种操作的处理方法,共同提高对系统的认识水平。
5测试配置
测试配置应该尽量自动完成,减少工作量。
测试配置包括如下内容:
 测试工具的配置
 测试环境,如数据、数据库结构
6测试初始设置
一些测试用例相互依赖,本应该把它们合成一个测试用例;但是如果单个测试用例颗粒很大,那么在回归测试或再现缺陷时就会使人发疯,并且浪费了大量的测试时间。最好最可靠的解决办法看来只有一种,那就是将颗粒大的测试用例分离出来,同时为这个测试用例预备测试初始设置——将客户端所需要的数据库结构和数据库备份,并且作为测试初始设置保存管理。
这里的测试初始设置并非只针对自动化测试,手工测试也被包括进来。
6.1测试初始设置的命名办法
TE+测试用例编号
如测试用例为TC1.2,则TE为TE1.2
6.2测试初始设置的保存
测试初始设置应保存在单独的文件夹内,初始设置的路径被链接到Test driver上。查看(379) 评论(0) 收藏 分享 管理
一篇关于session的好文章,写的很详细(转载)
2008-09-03 16:37:45

一、术语session
二、HTTP协议与状态保持
三、理解cookie机制
四、理解session机制
五、理解javax.servlet.http.HttpSession
六、HttpSession常见问题
七、跨应用程序的session共享
八、总结
参考文档
一、术语session
在我的经验里,session这个词被滥用的程度大概仅次于transaction,更加有趣的是transaction与session在某些语境下的含义是相同的。

session,中文经常翻译为会话,其本来的含义是指有始有终的一系列动作/消息,比如打电话时从拿起电话拨号到挂断电话这中间的一系列过程可以称之为一个 session。有时候我们可以看到这样的话“在一个浏览器会话期间,...”,这里的会话一词用的就是其本义,是指从一个浏览器窗口打开到关闭这个期间 ①。最混乱的是“用户(客户端)在一次会话期间”这样一句话,它可能指用户的一系列动作(一般情况下是同某个具体目的相关的一系列动作,比如从登录到选购商品到结账登出这样一个网上购物的过程,有时候也被称为一个transaction),然而有时候也可能仅仅是指一次连接,也有可能是指含义①,其中的差别只能靠上下文来推断②。

然而当session一词与网络协议相关联时,它又往往隐含了“面向连接”和/或“保持状态”这样两个含义, “面向连接”指的是在通信双方在通信之前要先建立一个通信的渠道,比如打电话,直到对方接了电话通信才能开始,与此相对的是写信,在你把信发出去的时候你并不能确认对方的地址是否正确,通信渠道不一定能建立,但对发信人来说,通信已经开始了。“保持状态”则是指通信的一方能够把一系列的消息关联起来,使得消息之间可以互相依赖,比如一个服务员能够认出再次光临的老顾客并且记得上次这个顾客还欠店里一块钱。这一类的例子有“一个TCP session”或者 “一个POP3 session”③。

而到了web服务器蓬勃发展的时代,session在web开发语境下的语义又有了新的扩展,它的含义是指一类用来在客户端与服务器之间保持状态的解决方案④。有时候session也用来指这种解决方案的存储结构,如“把xxx保存在session 里”⑤。由于各种用于web开发的语言在一定程度上都提供了对这种解决方案的支持,所以在某种特定语言的语境下,session也被用来指代该语言的解决方案,比如经常把Java里提供的javax.servlet.http.HttpSession简称为session⑥。

鉴于这种混乱已不可改变,本文中session一词的运用也会根据上下文有不同的含义,请大家注意分辨。
在本文中,使用中文“浏览器会话期间”来表达含义①,使用“session机制”来表达含义④,使用“session”表达含义⑤,使用具体的“HttpSession”来表达含义⑥

二、HTTP协议与状态保持
HTTP 协议本身是无状态的,这与HTTP协议本来的目的是相符的,客户端只需要简单的向服务器请求下载某些文件,无论是客户端还是服务器都没有必要纪录彼此过去的行为,每一次请求之间都是独立的,好比一个顾客和一个自动售货机或者一个普通的(非会员制)大卖场之间的关系一样。

然而聪明(或者贪心?)的人们很快发现如果能够提供一些按需生成的动态信息会使web变得更加有用,就像给有线电视加上点播功能一样。这种需求一方面迫使HTML逐步添加了表单、脚本、DOM等客户端行为,另一方面在服务器端则出现了CGI规范以响应客户端的动态请求,作为传输载体的HTTP协议也添加了文件上载、 cookie这些特性。其中cookie的作用就是为了解决HTTP协议无状态的缺陷所作出的努力。至于后来出现的session机制则是又一种在客户端与服务器之间保持状态的解决方案。

让我们用几个例子来描述一下cookie和session机制之间的区别与联系。笔者曾经常去的一家咖啡店有喝5杯咖啡免费赠一杯咖啡的优惠,然而一次性消费5杯咖啡的机会微乎其微,这时就需要某种方式来纪录某位顾客的消费数量。想象一下其实也无外乎下面的几种方案:
1、该店的店员很厉害,能记住每位顾客的消费数量,只要顾客一走进咖啡店,店员就知道该怎么对待了。这种做法就是协议本身支持状态。
2、发给顾客一张卡片,上面记录着消费的数量,一般还有个有效期限。每次消费时,如果顾客出示这张卡片,则此次消费就会与以前或以后的消费相联系起来。这种做法就是在客户端保持状态。
3、发给顾客一张会员卡,除了卡号之外什么信息也不纪录,每次消费时,如果顾客出示该卡片,则店员在店里的纪录本上找到这个卡号对应的纪录添加一些消费信息。这种做法就是在服务器端保持状态。

由于HTTP协议是无状态的,而出于种种考虑也不希望使之成为有状态的,因此,后面两种方案就成为现实的选择。具体来说cookie机制采用的是在客户端保持状态的方案,而session机制采用的是在服务器端保持状态的方案。同时我们也看到,由于采用服务器端保持状态的方案在客户端也需要保存一个标识,所以session机制可能需要借助于cookie机制来达到保存标识的目的,但实际上它还有其他选择。

三、理解cookie机制
cookie机制的基本原理就如上面的例子一样简单,但是还有几个问题需要解决:“会员卡”如何分发;“会员卡”的内容;以及客户如何使用“会员卡”。

正统的cookie分发是通过扩展HTTP协议来实现的,服务器通过在HTTP的响应头中加上一行特殊的指示以提示浏览器按照指示生成相应的cookie。然而纯粹的客户端脚本如Javascrīpt或者VBscrīpt也可以生成cookie。

而cookie 的使用是由浏览器按照一定的原则在后台自动发送给服务器的。浏览器检查所有存储的cookie,如果某个cookie所声明的作用范围大于等于将要请求的资源所在的位置,则把该cookie附在请求资源的HTTP请求头上发送给服务器。意思是麦当劳的会员卡只能在麦当劳的店里出示,如果某家分店还发行了自己的会员卡,那么进这家店的时候除了要出示麦当劳的会员卡,还要出示这家店的会员卡。

cookie的内容主要包括:名字,值,过期时间,路径和域。
其中域可以指定某一个域比如.google.com,相当于总店招牌,比如宝洁公司,也可以指定一个域下的具体某台机器比如www.google.com或者froogle.google.com,可以用飘柔来做比。
路径就是跟在域名后面的URL路径,比如/或者/foo等等,可以用某飘柔专柜做比。
路径与域合在一起就构成了cookie的作用范围。
如果不设置过期时间,则表示这个cookie的生命期为浏览器会话期间,只要关闭浏览器窗口,cookie就消失了。这种生命期为浏览器会话期的 cookie被称为会话cookie。会话cookie一般不存储在硬盘上而是保存在内存里,当然这种行为并不是规范规定的。如果设置了过期时间,浏览器就会把cookie保存到硬盘上,关闭后再次打开浏览器,这些cookie仍然有效直到超过设定的过期时间。

存储在硬盘上的cookie 可以在不同的浏览器进程间共享,比如两个IE窗口。而对于保存在内存里的cookie,不同的浏览器有不同的处理方式。对于IE,在一个打开的窗口上按 Ctrl-N(或者从文件菜单)打开的窗口可以与原窗口共享,而使用其他方式新开的IE进程则不能共享已经打开的窗口的内存cookie;对于 Mozilla Firefox0.8,所有的进程和标签页都可以共享同样的cookie。一般来说是用javascrīpt的window.open打开的窗口会与原窗口共享内存cookie。浏览器对于会话cookie的这种只认cookie不认人的处理方式经常给采用session机制的web应用程序开发者造成很大的困扰。

下面就是一个goolge设置cookie的响应头的例子
HTTP/1.1 302 Found
Location: http://www.google.com/intl/zh-CN/
Set-Cookie: PREF=ID=0565f77e132de138:NW=1:TM=1098082649:LM=1098082649:S=KaeaCFPo49RiA_d8; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
Content-Type: text/html

这是使用HTTPLook这个HTTP Sniffer软件来俘获的HTTP通讯纪录的一部分

浏览器在再次访问goolge的资源时自动向外发送cookie

使用Firefox可以很容易的观察现有的cookie的值
使用HTTPLook配合Firefox可以很容易的理解cookie的工作原理。

IE也可以设置在接受cookie前询问

这是一个询问接受cookie的对话框。

四、理解session机制
session机制是一种服务器端的机制,服务器使用一种类似于散列表的结构(也可能就是使用散列表)来保存信息。

当程序需要为某个客户端的请求创建一个session的时候,服务器首先检查这个客户端的请求里是否已包含了一个session标识 - 称为 session id,如果已包含一个session id则说明以前已经为此客户端创建过session,服务器就按照session id把这个 session检索出来使用(如果检索不到,可能会新建一个),如果客户端请求不包含session id,则为此客户端创建一个session并且生成一个与此session相关联的session id,session id的值应该是一个既不会重复,又不容易被找到规律以仿造的字符串,这个 session id将被在本次响应中返回给客户端保存。

保存这个session id的方式可以采用cookie,这样在交互过程中浏览器可以自动的按照规则把这个标识发挥给服务器。一般这个cookie的名字都是类似于SEEESIONID,而。比如weblogic对于web应用程序生成的cookie,JSESSIONID= ByOK3vjFD75aPnrF7C2HmdnV6QZcEbzWoWiBYEnLerjQ99zWpBng!-145788764,它的名字就是 JSESSIONID。

由于cookie可以被人为的禁止,必须有其他机制以便在cookie被禁止时仍然能够把session id传递回服务器。经常被使用的一种技术叫做URL重写,就是把session id直接附加在URL路径的后面,附加方式也有两种,一种是作为URL路径的附加信息,表现形式为http://...../xxx;jsessionid= ByOK3vjFD75aPnrF7C2HmdnV6QZcEbzWoWiBYEnLerjQ99zWpBng!-145788764
另一种是作为查询字符串附加在URL后面,表现形式为http://...../xxx?jsessionid=ByOK3vjFD75aPnrF7C2HmdnV6QZcEbzWoWiBYEnLerjQ99zWpBng!-145788764
这两种方式对于用户来说是没有区别的,只是服务器在解析的时候处理的方式不同,采用第一种方式也有利于把session id的信息和正常程序参数区分开来。
为了在整个交互过程中始终保持状态,就必须在每个客户端可能请求的路径后面都包含这个session id。

另一种技术叫做表单隐藏字段。就是服务器会自动修改表单,添加一个隐藏字段,以便在表单提交时能够把session id传递回服务器。比如下面的表单



在被传递给客户端之前将被改写成




这种技术现在已较少应用,笔者接触过的很古老的iPlanet6(SunONE应用服务器的前身)就使用了这种技术。
实际上这种技术可以简单的用对action应用URL重写来代替。

在谈论session机制的时候,常常听到这样一种误解“只要关闭浏览器,session就消失了”。其实可以想象一下会员卡的例子,除非顾客主动对店家提出销卡,否则店家绝对不会轻易删除顾客的资料。对session来说也是一样的,除非程序通知服务器删除一个session,否则服务器会一直保留,程序一般都是在用户做log off的时候发个指令去删除session。然而浏览器从来不会主动在关闭之前通知服务器它将要关闭,因此服务器根本不会有机会知道浏览器已经关闭,之所以会有这种错觉,是大部分session机制都使用会话cookie来保存session id,而关闭浏览器后这个 session id就消失了,再次连接服务器时也就无法找到原来的session。如果服务器设置的cookie被保存到硬盘上,或者使用某种手段改写浏览器发出的HTTP请求头,把原来的session id发送给服务器,则再次打开浏览器仍然能够找到原来的session。

恰恰是由于关闭浏览器不会导致session被删除,迫使服务器为seesion设置了一个失效时间,当距离客户端上一次使用session的时间超过这个失效时间时,服务器就可以认为客户端已经停止了活动,才会把session删除以节省存储空间。

五、理解javax.servlet.http.HttpSession
HttpSession是Java平台对session机制的实现规范,因为它仅仅是个接口,具体到每个web应用服务器的提供商,除了对规范支持之外,仍然会有一些规范里没有规定的细微差异。这里我们以BEA的Weblogic Server8.1作为例子来演示。

首先,Weblogic Server提供了一系列的参数来控制它的HttpSession的实现,包括使用cookie的开关选项,使用URL重写的开关选项,session持久化的设置,session失效时间的设置,以及针对cookie的各种设置,比如设置cookie的名字、路径、域, cookie的生存时间等。

一般情况下,session都是存储在内存里,当服务器进程被停止或者重启的时候,内存里的session也会被清空,如果设置了session的持久化特性,服务器就会把session保存到硬盘上,当服务器进程重新启动或这些信息将能够被再次使用, Weblogic Server支持的持久性方式包括文件、数据库、客户端cookie保存和复制。

复制严格说来不算持久化保存,因为session实际上还是保存在内存里,不过同样的信息被复制到各个cluster内的服务器进程中,这样即使某个服务器进程停止工作也仍然可以从其他进程中取得session。

cookie生存时间的设置则会影响浏览器生成的cookie是否是一个会话cookie。默认是使用会话cookie。有兴趣的可以用它来试验我们在第四节里提到的那个误解。

cookie的路径对于web应用程序来说是一个非常重要的选项,Weblogic Server对这个选项的默认处理方式使得它与其他服务器有明显的区别。后面我们会专题讨论。

关于session的设置参考[5] http://e-docs.bea.com/wls/docs70/webapp/weblogic_xml.html#1036869

六、HttpSession常见问题
(在本小节中session的含义为⑤和⑥的混合)


1、session在何时被创建
一个常见的误解是以为session在有客户端访问时就被创建,然而事实是直到某server端程序调用 HttpServletRequest.getSession(true)这样的语句时才被创建,注意如果JSP没有显示的使用 <% @page session="false"%> 关闭session,则JSP文件在编译成Servlet时将会自动加上这样一条语句 HttpSession session = HttpServletRequest.getSession(true);这也是JSP中隐含的 session对象的来历。

由于session会消耗内存资源,因此,如果不打算使用session,应该在所有的JSP中关闭它。

2、session何时被删除
综合前面的讨论,session在下列情况下被删除a.程序调用HttpSession.invalidate();或b.距离上一次收到客户端发送的session id时间间隔超过了session的超时设置;或c.服务器进程被停止(非持久session)

3、如何做到在浏览器关闭时删除session
严格的讲,做不到这一点。可以做一点努力的办法是在所有的客户端页面里使用javascrīpt代码window.oncolose来监视浏览器的关闭动作,然后向服务器发送一个请求来删除session。但是对于浏览器崩溃或者强行杀死进程这些非常规手段仍然无能为力。

4、有个HttpSessionListener是怎么回事
你可以创建这样的listener去监控session的创建和销毁事件,使得在发生这样的事件时你可以做一些相应的工作。注意是session的创建和销毁动作触发listener,而不是相反。类似的与HttpSession有关的listener还有 HttpSessionBindingListener,HttpSessionActivationListener和 HttpSessionAttributeListener。

5、存放在session中的对象必须是可序列化的吗
不是必需的。要求对象可序列化只是为了session能够在集群中被复制或者能够持久保存或者在必要时server能够暂时把session交换出内存。在 Weblogic Server的session中放置一个不可序列化的对象在控制台上会收到一个警告。我所用过的某个iPlanet版本如果 session中有不可序列化的对象,在session销毁时会有一个Exception,很奇怪。

6、如何才能正确的应付客户端禁止cookie的可能性
对所有的URL使用URL重写,包括超链接,form的action,和重定向的URL,具体做法参见[6]
http://e-docs.bea.com/wls/docs70/webapp/sessions.html#100770

7、开两个浏览器窗口访问应用程序会使用同一个session还是不同的session
参见第三小节对cookie的讨论,对session来说是只认id不认人,因此不同的浏览器,不同的窗口打开方式以及不同的cookie存储方式都会对这个问题的答案有影响。

8、如何防止用户打开两个浏览器窗口操作导致的session混乱
这个问题与防止表单多次提交是类似的,可以通过设置客户端的令牌来解决。就是在服务器每次生成一个不同的id返回给客户端,同时保存在session里,客户端提交表单时必须把这个id也返回服务器,程序首先比较返回的id与保存在session里的值是否一致,如果不一致则说明本次操作已经被提交过了。可以参看《J2EE核心模式》关于表示层模式的部分。需要注意的是对于使用javascrīpt window.open打开的窗口,一般不设置这个id,或者使用单独的id,以防主窗口无法操作,建议不要再window.open打开的窗口里做修改操作,这样就可以不用设置。

9、为什么在Weblogic Server中改变session的值后要重新调用一次session.setValue
做这个动作主要是为了在集群环境中提示Weblogic Server session中的值发生了改变,需要向其他服务器进程复制新的session值。

10、为什么session不见了
排除session正常失效的因素之外,服务器本身的可能性应该是微乎其微的,虽然笔者在iPlanet6SP1加若干补丁的Solaris版本上倒也遇到过;浏览器插件的可能性次之,笔者也遇到过3721插件造成的问题;理论上防火墙或者代理服务器在cookie处理上也有可能会出现问题。
出现这一问题的大部分原因都是程序的错误,最常见的就是在一个应用程序中去访问另外一个应用程序。我们在下一节讨论这个问题。

七、跨应用程序的session共享

常常有这样的情况,一个大项目被分割成若干小项目开发,为了能够互不干扰,要求每个小项目作为一个单独的web应用程序开发,可是到了最后突然发现某几个小项目之间需要共享一些信息,或者想使用session来实现SSO(single sign on),在session中保存login的用户信息,最自然的要求是应用程序间能够访问彼此的session。

然而按照Servlet规范,session的作用范围应该仅仅限于当前应用程序下,不同的应用程序之间是不能够互相访问对方的session的。各个应用服务器从实际效果上都遵守了这一规范,但是实现的细节却可能各有不同,因此解决跨应用程序session共享的方法也各不相同。

首先来看一下Tomcat是如何实现web应用程序之间session的隔离的,从 Tomcat设置的cookie路径来看,它对不同的应用程序设置的cookie路径是不同的,这样不同的应用程序所用的session id是不同的,因此即使在同一个浏览器窗口里访问不同的应用程序,发送给服务器的session id也可以是不同的。

根据这个特性,我们可以推测Tomcat中session的内存结构大致如下。

笔者以前用过的iPlanet也采用的是同样的方式,估计SunONE与iPlanet之间不会有太大的差别。对于这种方式的服务器,解决的思路很简单,实际实行起来也不难。要么让所有的应用程序共享一个session id,要么让应用程序能够获得其他应用程序的session id。

iPlanet中有一种很简单的方法来实现共享一个session id,那就是把各个应用程序的cookie路径都设为/(实际上应该是/NASApp,对于应用程序来讲它的作用相当于根)。

/NASApp


需要注意的是,操作共享的session应该遵循一些编程约定,比如在session attribute名字的前面加上应用程序的前缀,使得 setAttribute("name", "neo")变成setAttribute("app1.name", "neo"),以防止命名空间冲突,导致互相覆盖。


在Tomcat中则没有这么方便的选择。在Tomcat版本3上,我们还可以有一些手段来共享session。对于版本4以上的Tomcat,目前笔者尚未发现简单的办法。只能借助于第三方的力量,比如使用文件、数据库、JMS或者客户端cookie,URL参数或者隐藏字段等手段。

我们再看一下Weblogic Server是如何处理session的。

从截屏画面上可以看到Weblogic Server对所有的应用程序设置的cookie的路径都是/,这是不是意味着在Weblogic Server中默认的就可以共享session了呢?然而一个小实验即可证明即使不同的应用程序使用的是同一个session,各个应用程序仍然只能访问自己所设置的那些属性。这说明Weblogic Server中的session的内存结构可能如下

对于这样一种结构,在 session机制本身上来解决session共享的问题应该是不可能的了。除了借助于第三方的力量,比如使用文件、数据库、JMS或者客户端 cookie,URL参数或者隐藏字段等手段,还有一种较为方便的做法,就是把一个应用程序的session放到ServletContext中,这样另外一个应用程序就可以从ServletContext中取得前一个应用程序的引用。示例代码如下,

应用程序A
context.setAttribute("appA", session);

应用程序B
contextA = context.getContext("/appA");
HttpSession sessionA = (HttpSession)contextA.getAttribute("appA");

值得注意的是这种用法不可移植,因为根据ServletContext的JavaDoc,应用服务器可以处于安全的原因对于context.getContext("/appA");返回空值,以上做法在Weblogic Server 8.1中通过。

那么Weblogic Server为什么要把所有的应用程序的cookie路径都设为/呢?原来是为了SSO,凡是共享这个session的应用程序都可以共享认证的信息。一个简单的实验就可以证明这一点,修改首先登录的那个应用程序的描述符weblogic.xml,把cookie路径修改为/appA 访问另外一个应用程序会重新要求登录,即使是反过来,先访问cookie路径为/的应用程序,再访问修改过路径的这个,虽然不再提示登录,但是登录的用户信息也会丢失。注意做这个实验时认证方式应该使用FORM,因为浏览器和web服务器对basic认证方式有其他的处理方式,第二次请求的认证不是通过 session来实现的。具体请参看[7] secion 14.8 Authorization,你可以修改所附的示例程序来做这些试验。

八、总结
session机制本身并不复杂,然而其实现和配置上的灵活性却使得具体情况复杂多变。这也要求我们不能把仅仅某一次的经验或者某一个浏览器,服务器的经验当作普遍适用的经验,而是始终需要具体情况具体分析。
摘要:虽然session机制在web应用程序中被采用已经很长时间了,但是仍然有很多人不清楚session机制的本质,以至不能正确的应用这一技术。本文将详细讨论session的工作机制并且对在Java web application中应用session机制时常见的问题作出解答

cookies

how to look at cookies using firefox?
tools->options->privacy->show cookies

Cookie Testing

http://www.softwaretestinghelp.com/website-cookie-testing-test-cases/

We will first focus on what exactly cookies are and how they work. It would be easy for you to understand the test cases for testing cookies when you have clear understanding of how cookies work? How cookies stored on hard drive? And how can we edit cookie settings?

What is Cookie?
Cookie is small information stored in text file on user’s hard drive by web server. This information is later used by web browser to retrieve information from that machine. Generally cookie contains personalized user data or information that is used to communicate between different web pages.

Why Cookies are used?
Cookies are nothing but the user’s identity and used to track where the user navigated throughout the web site pages. The communication between web browser and web server is stateless.

For example if you are accessing domain http://www.example.com/1.html then web browser will simply query to example.com web server for the page 1.html. Next time if you type page as http://www.example.com/2.html then new request is send to example.com web server for sending 2.html page and web server don’t know anything about to whom the previous page 1.html served.

What if you want the previous history of this user communication with the web server? You need to maintain the user state and interaction between web browser and web server somewhere. This is where cookie comes into picture. Cookies serve the purpose of maintaining the user interactions with web server.

How cookies work?
The HTTP protocol used to exchange information files on the web is used to maintain the cookies. There are two types of HTTP protocol. Stateless HTTP and Stateful HTTP protocol. Stateless HTTP protocol does not keep any record of previously accessed web page history. While Stateful HTTP protocol do keep some history of previous web browser and web server interactions and this protocol is used by cookies to maintain the user interactions.

Whenever user visits the site or page that is using cookie, small code inside that HTML page (Generally a call to some language script to write the cookie like cookies in JAVAScript, PHP, Perl) writes a text file on users machine called cookie.
Here is one example of the code that is used to write cookie and can be placed inside any HTML page:

Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME;

When user visits the same page or domain later time this cookie is read from disk and used to identify the second visit of the same user on that domain. Expiration time is set while writing the cookie. This time is decided by the application that is going to use the cookie.

Generally two types of cookies are written on user machine.

1) Session cookies: This cookie is active till the browser that invoked the cookie is open. When we close the browser this session cookie gets deleted. Some time session of say 20 minutes can be set to expire the cookie.
2) Persistent cookies: The cookies that are written permanently on user machine and lasts for months or years.

Where cookies are stored?
When any web page application writes cookie it get saved in a text file on user hard disk drive. The path where the cookies get stored depends on the browser. Different browsers store cookie in different paths. E.g. Internet explorer store cookies on path “C:\Documents and Settings\Default User\Cookies”
Here the “Default User” can be replaced by the current user you logged in as. Like “Administrator”, or user name like “Vijay” etc.
The cookie path can be easily found by navigating through the browser options. In Mozilla Firefox browser you can even see the cookies in browser options itself. Open the Mozila browser, click on Tools->Options->Privacy and then “Show cookies” button.

How cookies are stored?
Lets take example of cookie written by rediff.com on Mozilla Firefox browser:
On Mozilla Firefox browser when you open the page rediff.com or login to your rediffmail account, a cookie will get written on your Hard disk. To view this cookie simply click on “Show cookies” button mentioned on above path. Click on Rediff.com site under this cookie list. You can see different cookies written by rediff domain with different names.

Site: Rediff.com Cookie name: RMID
Name: RMID (Name of the cookie)
Content: 1d11c8ec44bf49e0… (Encrypted content)
Domain: .rediff.com
Path: / (Any path after the domain name)
Send For: Any type of connection
Expires: Thursday, December 31, 2020 11:59:59 PM

Applications where cookies can be used:

1) To implement shopping cart:
Cookies are used for maintaining online ordering system. Cookies remember what user wants to buy. What if user adds some products in their shopping cart and if due to some reason user don’t want to buy those products this time and closes the browser window? When next time same user visits the purchase page he can see all the products he added in shopping cart in his last visit.

2) Personalized sites:
When user visits certain pages they are asked which pages they don’t want to visit or display. User options are get stored in cookie and till the user is online, those pages are not shown to him.

3) User tracking:
To track number of unique visitors online at particular time.

4) Marketing:
Some companies use cookies to display advertisements on user machines. Cookies control these advertisements. When and which advertisement should be shown? What is the interest of the user? Which keywords he searches on the site? All these things can be maintained using cookies.

5) User sessions:
Cookies can track user sessions to particular domain using user ID and password.

Drawbacks of cookies:

1) Even writing Cookie is a great way to maintain user interaction, if user has set browser options to warn before writing any cookie or disabled the cookies completely then site containing cookie will be completely disabled and can not perform any operation resulting in loss of site traffic.

2) Too many Cookies:
If you are writing too many cookies on every page navigation and if user has turned on option to warn before writing cookie, this could turn away user from your site.

3) Security issues:
Some times users personal information is stored in cookies and if someone hack the cookie then hacker can get access to your personal information. Even corrupted cookies can be read by different domains and lead to security issues.

4) Sensitive information:
Some sites may write and store your sensitive information in cookies, which should not be allowed due to privacy concerns.

This should be enough to know what cookies are. If you want more cookie info see Cookie Central page.

Some Major Test cases for web application cookie testing:

The first obvious test case is to test if your application is writing cookies properly on disk. You can use the Cookie Tester application also if you don’t have any web application to test but you want to understand the cookie concept for testing.

Test cases:

1) As a Cookie privacy policy make sure from your design documents that no personal or sensitive data is stored in the cookie.

2) If you have no option than saving sensitive data in cookie make sure data stored in cookie is stored in encrypted format.

3) Make sure that there is no overuse of cookies on your site under test. Overuse of cookies will annoy users if browser is prompting for cookies more often and this could result in loss of site traffic and eventually loss of business.

4) Disable the cookies from your browser settings: If you are using cookies on your site, your sites major functionality will not work by disabling the cookies. Then try to access the web site under test. Navigate through the site. See if appropriate messages are displayed to user like “For smooth functioning of this site make sure that cookies are enabled on your browser”. There should not be any page crash due to disabling the cookies. (Please make sure that you close all browsers, delete all previously written cookies before performing this test)

5) Accepts/Reject some cookies: The best way to check web site functionality is, not to accept all cookies. If you are writing 10 cookies in your web application then randomly accept some cookies say accept 5 and reject 5 cookies. For executing this test case you can set browser options to prompt whenever cookie is being written to disk. On this prompt window you can either accept or reject cookie. Try to access major functionality of web site. See if pages are getting crashed or data is getting corrupted.

6) Delete cookie: Allow site to write the cookies and then close all browsers and manually delete all cookies for web site under test. Access the web pages and check the behavior of the pages.

7) Corrupt the cookies: Corrupting cookie is easy. You know where cookies are stored. Manually edit the cookie in notepad and change the parameters to some vague values. Like alter the cookie content, Name of the cookie or expiry date of the cookie and see the site functionality. In some cases corrupted cookies allow to read the data inside it for any other domain. This should not happen in case of your web site cookies. Note that the cookies written by one domain say rediff.com can’t be accessed by other domain say yahoo.com unless and until the cookies are corrupted and someone trying to hack the cookie data.

8 ) Checking the deletion of cookies from your web application page: Some times cookie written by domain say rediff.com may be deleted by same domain but by different page under that domain. This is the general case if you are testing some ‘action tracking’ web portal. Action tracking or purchase tracking pixel is placed on the action web page and when any action or purchase occurs by user the cookie written on disk get deleted to avoid multiple action logging from same cookie. Check if reaching to your action or purchase page deletes the cookie properly and no more invalid actions or purchase get logged from same user.

9) Cookie Testing on Multiple browsers: This is the important case to check if your web application page is writing the cookies properly on different browsers as intended and site works properly using these cookies. You can test your web application on Major used browsers like Internet explorer (Various versions), Mozilla Firefox, Netscape, Opera etc.

10) If your web application is using cookies to maintain the logging state of any user then log in to your web application using some username and password. In many cases you can see the logged in user ID parameter directly in browser address bar. Change this parameter to different value say if previous user ID is 100 then make it 101 and press enter. The proper access message should be displayed to user and user should not be able to see other users account.

These are some Major test cases to be considered while testing website cookies. You can write multiple test cases from these test cases by performing various combinations. If you have some different application scenario, you can mention your test cases in comments below.

SQL refresh

DDL - Data Defination Language ( CREAT,ALTER, DROP,RENAME)
DML -Date Munipulation Language (SELECT, INSERT,UPDATE,DELETE)
TCL - Transaction Control Language
DCL - Data Control Language

CREATE TABLE employee ( id number(5), name char(20),dept char(10),age number(2), salary number(10) );

ALTER TABLE employee MODIFY salary number(10,2);
ALTER TABLE employee ADD phone number(10);
ALTER TABLE employee DROP age;

RENAME employee to my_employee

SELECT name FROM employee
WHERE age>35
GROUP BY dept
ORDER BY id

Wednesday, April 13, 2011

1.exe vbs to run a test and return a bolean value.

2.sample load/stress test cases. load testing: test the system responding time when a number of users using the same application at the same time. stress testing. when more users than the systems allows using the same application, how the system behave. Performance Testing: VBscript: Dim If..Else InStr

3.text and run-time objects

4.add object to Object Repositories

5.Add standard check point to check the display of drop down menu.

Monday, April 11, 2011

Testing Tools

1. Function and regression:

QTP(VBscript) Winrunner(TSL) Selenium; Watir

2. Performance: Loadrunner. OpenSTA

3. Test Management: QC (Quality Center) /TD(Test Director)
, JIRA, Testlink(open source)

winsock

short for Windows Socket, an API(application program interface) for developing Windows programs that can communicate with other machines via the TCP/IP protocal. Windows 95 and Windows NT comes with Dynamic Link ibrary (DLL) called winsock.dll that implements the API and acts as the glue between Windows programs and TCP/IP connection.

B/S and C/S structure

B/S: Browser/Server
C/S: Client/Server

Saturday, April 9, 2011

create a file and run it.

touch newexe.sh
vi newexe.sh
insert->
mkdir qq
esc->
:wq!
cat newexe.sh
chmod 777 newexe.sh
./newexe.sh

Friday, April 8, 2011

Linux

ls -a
-l
pwd print working directory
mkdir -m
rmdir -p
chmod 777
touch

Methods of test cases design

White-Box Testing:
逻辑覆盖Logic Coverage
语句覆盖 Statement coverage
判定覆盖 Decision coverage
条件覆盖Condition coverage
条件组合覆盖 Condition combination coverage
路径覆盖 Path coverage

Black-Box Testing:
等价划分法Equivalence Partitioning Method选取小量有代表性的输入数据,以期用较小的代价暴露较多的程序错误。Select minor representative
input data to expect more program error discovered with less cost.
边界值法Boundary Value Method处理边界情况时程序最容易发生错误。使用边界值选择一组测试用例,检查程序处理边界数值的能力
Errors occur easily when the program deals with boundary circumstance. Use the boundary value to
choose one set of test cases, to check the capability of processing boundary value.
规格导出法(Specification Export Method )根据相关的规范描述来设计测试用例。每一个测试用例用来测试一个或多个规范陈述语句。Design
test cases according to the relative criterions. Each test case can be used to test one or more
statement in the criterions.
例如,考虑一个计算平方根的函数的规范For example, consider the criterion of calculating the
square root of a function.
输入:实数 Input: real number
输出:实数Output: real number
规范:当输入一个0 或大于0 的数时,返回其正的平方根;当输入一个小于0 的数时,显示错误信息,
并返回0。
输入输出组合法Combination Method of Input and Output
“CRUD”覆盖法"CRUD" Coverage Method

verification & validation

What is verification? validation?
Verification typically involves reviews and meetings to evaluate documents, plans, code, requirements, and specifications. This can be done with checklists, issues lists, walkthroughs, and inspection meetings.

Validation typically involves actual testing and takes place after verifications are completed.

Testing Types

Black box testingnot based on any knowledge of internal design or code. Tests are based on requirements and functionality.
White box testingbased on knowledge of the internal logic of an application’s code. Tests are based on coverage of code statements, branches, paths, conditions.
Unit testingthe most ‘micro’ scale of testing; to test particular functions or code modules. Typically done by the programmer and not by testers, as it requires detailed knowledge of the internal program design and code. Not always easily done unless the application has a well-designed architecture with tight code; may require developing test driver modules or test harnesses.
Incremental integration testingcontinuous testing of an application as new functionality is added; requires that various aspects of an application’s functionality be independent enough to work separately before all parts of the program are completed, or that test drivers be developed as needed; done by programmers or by testers.
Integration testingtesting of combined parts of an application to determine if they function together correctly. The ‘parts’ can be code modules, individual applications, client and server applications on a network, etc. This type of testing is especially relevant to client/server and distributed systems.

Functional testingblack-box type testing geared to functional requirements of an application; this type of testing should be done by testers. This doesn’t mean that the programmers shouldn’t check that their code works before releasing it (which of course applies to any stage of testing.)
System testingblack box type testing that is based on overall requirement specifications; covers all combined parts of a system.
End-to-end testingsimilar to system testing; the ‘macro’ end of the test scale; involves testing of a complete application environment in a situation that mimics real-world use, such as interacting with a database, using network communications, or interacting with other hardware, applications, or systems if appropriate.
Sanity testing
typically an initial testing effort to determine if a new software version is performing well enough to accept it for a major testing effort. For example, if the new software is crashing systems every 5 minutes, bogging down systems to a crawl, or destroying databases, the software may not be in a ’sane’ enough condition to warrant further testing in its current state.
Regression testingre-testing after fixes or modifications of the software or its environment. It can be difficult to determine how much re-testing is needed, especially near the end of the development cycle. Automated testing tools can be especially useful for this type of testing.
Acceptance testingfinal testing based on specifications of the end-user or customer, or based on use by end-users/customers over some limited period of time.
Load testingtesting an application under heavy loads, such as testing of a web site under a range of loads to determine at what point the systems response time degrades or fails.
Stress testing
term often used interchangeably with ‘load’ and ‘performance’ testing. Also used to describe such tests as system functional testing while under unusually heavy loads, heavy repetition of certain actions or inputs, input of large numerical values, large complex queries to a database system, etc.
Performance testing
term often used interchangeably with ’stress’ and ‘load’ testing. Ideally ‘performance’ testing (and any other ‘type’ of testing) is defined in requirements documentation or QA or Test Plans.
Usability testing
testing for ‘user-friendliness’. Clearly this is subjective, and will depend on the targeted end-user or customer. User interviews, surveys, video recording of user sessions, and other techniques can be used. Programmers and testers are usually not appropriate as usability testers.
Install/uninstall testingtesting of full, partial, or upgrade install/uninstall processes.
Recovery testingtesting how well a system recovers from crashes, hardware failures, or other catastrophic problems.
Security testingtesting how well the system protects against unauthorized internal or external access, willful damage, etc; may require sophisticated testing techniques.
Compatibility testing
testing how well software performs in a particular hardware/software/operating system/network/etc. environment.
Exploratory testing
often taken to mean a creative, informal software test that is not based on formal test plans or test cases; testers may be learning the software as they test it.
Ad-hoc testing
similar to exploratory testing, but often taken to mean that the testers have significant understanding of the software before testing it.
User acceptance testing
determining if software is satisfactory to an end-user or customer.
Comparison testing
comparing software weaknesses and strengths to competing products.
Alpha testingtesting of an application when development is nearing completion; minor design changes may still be made as a result of such testing. Typically done by end-users or others, not by programmers or testers.
Beta testingtesting when development and testing are essentially completed and final bugs and problems need to be found before final release. Typically done by end-users or others, not by programmers or testers.
Mutation testing
a method for determining if a set of test data or test cases is useful, by deliberately introducing various code changes (’bugs’) and retesting with the original test data/cases to determine if the ‘bugs’ are detected. Proper implementation requires large computational resources.

Wednesday, April 6, 2011

Web Testing

WEB TESTING
While testing a web application you need to consider following Cases:

• Functionality Testing
• Performance Testing
• Usability Testing
• Server Side Interface
• Client Side Compatibility
• Security

Functionality:
In testing the functionality of the web sites the following should be tested:
• Links
i. Internal Links
ii. External Links
iii. Mail Links
iv. Broken Links

• Forms
i. Field validation
ii. Error message for wrong input
iii. Optional and Mandatory fields

• Database
* Testing will be done on the database integrity.

• Cookies
* Testing will be done on the client system side, on the temporary Internet files.

Performance :
Performance testing can be applied to understand the web site’s scalability, or to benchmark the performance in the environment of third party products such as servers and middleware for potential purchase.

• Connection Speed:
Tested over various networks like Dial Up, ISDN etc
• Load:
i. What is the no. of users per time?
ii. Check for peak loads and how system behaves
iii. Large amount of data accessed by user
• Stress:
i. Continuous Load
ii. Performance of memory, CPU, file handling etc..

Usability:
Usability testing is the process by which the human-computer interaction characteristics of a system are measured, and weaknesses are identified for correction.
• Ease of learning
• Navigation
• Subjective user satisfaction
• General appearance

Server Side Interface:
In web testing the server side interface should be tested. This is done by verify that communication is done properly. Compatibility of server with software, hardware, network and database should be tested.

Client Side Compatibility:
The client side compatibility is also tested in various platforms, using various browsers etc.

Security:
The primary reason for testing the security of a web is to identify potential vulnerabilities and subsequently repair them.
• Network Scanning
• Vulnerability Scanning
• Password Cracking
• Log Review
• Integrity Checkers
• Virus Detection

QTP Tutorial Summary

第一章:QTP测试步骤。 1:Analyze the application 确定应用程序的开发环境,在开启QTP的时候加载相应的add-in(active-X, VB, Web)。确定你需要测试哪些流程(business processes)或者功能(functionality)。思考怎么把流程分割成更小的单元,也就基于那些流程是创建action。这样使得test更加容易理解以及维护。 2:Prepare Resources 基于你的测试需求,确定你需要哪些资源(resource),然后创建这些资源,这些资源一般包括: [1]shared objects repositories,(这个里面包括test objects,这就是你测试的应用程序中的objects)。 [2]function libraries(这个里面存放一些函数,可以加强测试的功能) 3:Create a test and add steps 创建一个空的testà往test中加入action(形成一个test的框架)把之前准备好的resource与对应的action关联起来, 在action下通过关键字加入steps,在这一步,我们可能还需要进行参数设置等操作 4:Enhance the test [1]Add Checkpoint [2]Pparameterize [3]Add logic or loop statement 5:Run and Analyse test 6:报告测试出来的问题 第二章:action Action的类型:internal action:存放在别的test中,但是被应用的action。external action:存储在当前Test中的action。Reusable action允许在任何test中调用的action。Non-reusable action:是一种仅仅只能在当前test中使用的internal action。 A call to a new action:默认为reusable action A call to copy of action:这种action相当于一种internal action,在其他的test中调用该action时,和原test中的该action没有任何关联。 A call to exiting action :这种action只能在存储该action的test中修改,在调用该action的其他test中不能修改。 总结:如何创建action很关键,因为action直接影响到你整个test的架构。把要测试场景分割为多个action。每一个action完成特定的功能。 第三章:创建对象库 Object repository(.trs):包括test object, other type object, check points这些内容。而object repository又分两种类型:shared以及local Ashared object repository:这里面的内容可以在任何action中使用。【注意:我们最好是为我们应用程序或者web的每一个页面分别建立一个shared object repository,这样的话,方便我们在修改维护test的时候找到正确的object】 A local object repository:这里面的内容只能在特定的action中使用。 Test objects(包含在object repository中)以及Run-time objects(不包含在object repository中),关于这两个概念我一直没有理解。通过网上找到的一些资料,终于知道了。转载如下: 【QTP为用户提供了两种操作对象的接口,一种就是对象的封装接口,另一种是对象的自身接口。对象的自身接口是对象控件本身的接口,只要做过软件开发,使用过控件的人应该很清楚。对象的封装接口是QTP为对象封装的另一层接口,它是QTP通过调用对象的自身接口来实现的。两种接口的脚本书写格式的差别在于:自身接口需要在对象名后面加object再加属性名或方法名,封装接口就不用在对象名后面加object。 比如操作JavaEdit对象,通过QTP封装的封装接口,脚本如下: 设置JavaEdit的内容: JavaDialog("Add NE").JavaEdit("NE Name").Set "NE1" 读取JavaEdit的内容: msgbox JavaDialog("Add NE").JavaEdit("NE Name").GetROProperty("value") 如果通过JavaEdit的自身接口,脚本如下 设置JavaEdit的内容: JavaDialog("Add NE").JavaEdit("NE Name").object.setText("NE1") 读取JavaEdit的内容: Msgbox JavaDialog("Add NE").JavaEdit("NE Name").object.getText() QTP执行JavaEdit().Set语句时,是通过执行JavaEdit().object.setText()来实现的。 QTP执行JavaEdit().GetROProperty("value"),是通过执行JavaEdit().object.getText()来实现的。 JavaEdit对象的封装接口Set()和GetROProperty("value"),是QTP封装JavaEdit对象的自身接口setText()和getText()而得来的。 对象的封装接口是QTP使用的缺省接口,我们录制出来的脚本都是使用封装接口,大家用的也都是封装接口。但是封装接口不如自身接口丰富,因为QTP只是封装了部分常用的自身接口嘛。所以我们在需要时,可以绕过封装接口,直接调用对象的自身接口。不过有些自身接口不够稳定,在实践中偶尔会出现问题,但是概率很少。封装接口有相应功能的话,就尽量用封装接口吧!理解了封装接口和自身接口的原理,我们就可以更加灵活的操作对象了。但是我们怎么知道对象都有哪些封装接口和自身接口呢?其实很简单,用对象查看器(Object Spy)查看对象,在查看窗口里有列出这些接口,包括属性和方法。窗口中间有选择栏让你选择Run-time Object或者Test Object,当你选择Run-time Object时,它显示的就是对象的自身接口(自身的属性和方法)当你选择Test Object时,它显示的就是对象的封装接口(封装的属性和方法)明白了这些,你还等什么呢?快拿起对象查看器,看看对象都有哪些封装接口和自身接口,肆意的操作它。 比如执行 JavaDialog("Add NE").JavaEdit("NE Name").object.setVisible(false) 哈哈,你的JavaEdit对象就当场消失不见了!!!此部分内容为转载】 第四章:创建函数以及函数库可以创建自定义的函数放在函数库中,在测试的时候可以将需要的函数库与test结合,那么该Test就可以调用该函数库中的所有函数。(可以用VBS编写QTP脚本)自己编写的函数的后缀(.qfl) 第五章:创建test 创建test 创建action 关联object repository 关联function library 往action中添加step(从object repository中选择object或者自己编写object,描述性编程,或者通过step generator定义一整个step)。 第六章:创建检查点,使用函数添加检查点的方法:1:在record的时候添加 2:直接在修改脚本的过程中添加。 检查点的类型: 1:standard checkpoint 2:image checkpoint 3:table checkpoint 4:page checkpoint5:text checkpoint6:bitmap checkpoint 7:database checkpoint 8:accessibility checkpoint 9:xml checkpoint 10:text area checkpoint 通过函数执行检查:

CENTOS

http://en.wikipedia.org/wiki/CentOS
http://www.centos.org/

Tuesday, April 5, 2011

QTP

prepare web browser setting:
General->disable tabbed browsing Content->disable autocomplete username/pwd

QTP doesn't record:
进入DOS-->msconfig-->tools-->select UAC-->click launch button-->restart PC