-
qtp关键字框架实践总结
2012-10-08 16:36:26
自动化总结----关键字驱动总结
进过利用2个多月的空余时间完成了,完成自动化测试的第一版本(基本流程的自动化)。
一、设计思路及其框架
通过excel中的测试用例步骤,获取操作对象和数据信息。
框架的组成部分:
1、 测试用例:存放测试用例文档。
2、 函数集合
a) Web Function:负责操作对象的函数集,如单击按钮、双击按钮等;
b) Common function:公共函数,如生产随机数、去掉字符串的空格等;
c) Constant:存储常量;
d) Excel:存放对excel操作的函数集合,如打开excel、关闭excel等
3、 主action:负责运行测试用例的驱动。
4、 BugPictureManagement:存放错误的截图。
5、 Result:存放测试结果,格式为excel。
二、进度:附件是进度图
由于第一次实现预算执行系统流程自动化,我们对控件不熟悉,所以采取的方式为:
1、 先将所有的控件类型汇总。
2、 通过实现流程用例的方式,先完成流程用例的控件为操作为目的,完成此次自动化的任务。
3、 分配任务也是每个人负责不同的流程。
三、进度与风险的把控
第三季度刚开始的时候,按计划执行。到了8月份, 小组内2个人出差,1个人功能测试任务紧,是预计之外的风险!采取的措施:通过加班,赶上进度,完成任务。下次通过分配更多的时间,或者减少任务控制这个风险。
四、好的地方
1. 这个框架的好处是把关键字和数据放在用例维护,大大减少代码和对象仓库的维护量;
2. 测试用例大部分数据自动获得, 这样因为修改数据,而修改测试用例的工作少,且每次执行的数据都不一样;
3. 每次执行完一个用例, 根据日期新生成一个包含测试结果的测试用例。这样不论执行多少遍用例,结果都被保存, 且一目了然。
4. 出现错误会截屏,且会把发生错误的用例步骤打印到截屏上;
五、改进的地方
1. 把所有的控件放在一个表里;
2. 异常控制较少;
3. 等待时间没有自动;
4. 进一步规范测试用例语句;
六、总结
通过QTP小组的活动和实践,培养起组内人员对自动化的学习兴趣,组内人员有了vbscript的基础,了解自动化框架的基本思路,学会描述性对象编程, 并独立完成自动化脚本的编写(除了邓弋,因为他出差)。这个季度由于测试任务重,写代码的时间少。我希望在下个季度能够有相对多时间写代码,提高代码能力。
七、以后
目前只是完成基本流程的正向流程, 所以下次想找一个相对稳定的子系统做自动化测试,如指标管理。
-
java - mysql
2012-07-24 22:19:04
package db;
import java.sql.*;
public class database {/**
* @param args
*/
Connection conn;
Statement statement;
ResultSet rs;
String driver = "com.mysql.jdbc.Driver";// URL指向要访问的数据库名mytest
String url = "jdbc:mysql://localhost:3306/mytest";// MySQL配置时的用户名
String user = "root";
// Java连接MySQL配置时的密码
String password = "root";
/*连接数据库
* 连接成功返回ture
* 否则返回false
* */
public Boolean connectDB()
{
try {
// 加载驱动程序
Class.forName(driver);// 连续数据库
conn = DriverManager.getConnection(url, user, password);if(!conn.isClosed())
{System.out.println("Succeeded connecting to the Database!");
return false;
}
// statement用来执行SQL语句
statement = conn.createStatement();
} catch(ClassNotFoundException e)
{ System.out.println("Sorry,can`t find the Driver!");
e.printStackTrace();
} catch(SQLException e)
{ e.printStackTrace(); }
catch(Exception e)
{ e.printStackTrace();
}
return true;
}
/*运行select的sql语句
* 返回值为执行结果
* */
public ResultSet executeSql(String sql){try {
// 要执行的SQL语句
statement = conn.createStatement();
rs = statement.executeQuery(sql);
} catch(SQLException e)
{ e.printStackTrace(); }
catch(Exception e)
{ e.printStackTrace();
}
return rs;
}
/*运行除外select的sql语句
*
* */
public void executeUID(String sql){try {
// 要执行的SQL语句
statement = conn.createStatement();
statement.executeUpdate(sql);
} catch(SQLException e)
{ e.printStackTrace(); }
catch(Exception e)
{ e.printStackTrace();
}
}
/*
* 关闭数据库
*
* */
void closeDB()
{
try {
rs.close();
conn.close();
} catch(SQLException e)
{ e.printStackTrace(); }
catch(Exception e)
{ e.printStackTrace(); }
}
public static void main(String[] args) {
// TODO Auto-generated method stub
database test = new database();
test.connectDB();
test.executeSql( "select * from userinfo;");
test.executeUID("insert userinfo (username,password) values('5','5');");
test.executeUID("update userinfo set password = '00' where username='5';");
test.closeDB();}} -
mysql 和myeclipse的连接
2012-07-24 20:48:17
经过几天挣扎, myeclipse终于连接上数据库了:问题:myeclipse连接不上access数据库,原因:access是32位的, 而我的操作系统是64位, 所以失败于是我就转向安装64位的mysql, 途中还是一个尽的折腾, 下载好多软件不行, 最后在mysql的官方网站上下载,按照下面的方法,才可以MyEclipse连接MySQL的方法MyEclipse连接数据库是非常重要的下面我就讲解一下MyEclipse连接MySQL的方法,首先我们打开MyEclipse在工具栏上依次点击Window-->Open Perspective-->MyEclipse Database Explorer
在左侧出现的空白处单击右键选择New...
在新弹出的窗口里我们在Driver template下拉框中选择MySQL Connector/J
在Driver name随便起个名字,Coonection URL填上数据库地址(最后那个test是你要连接的数据库)
User name,Password依次填上用户名,密码,点击Driver JARs右面的Add JARs选择你的数据库驱动,然后点击Finish
这时我们在左面会看到新建的数据库,我们右键点击新建的数据库选择Open connection...
出现一个新窗口我们输入刚才的用户名,密码,点击OK
这时我们能看到在数据库中建的表,说明已经连接成功。
我们回到JAVA工程中(点右上角的有M的图标选项就能快速打开)在我们需要用到驱动的项目中点击右键选择Build Path-->Add Libraries...
然后在新弹出的窗口中选择User Library然后点击Next>
然后点击右侧的User Libraries...
在新出现的窗口中点击右侧的New...
我们给它随便起个名字,点击OK
选择你新建的那个aaa_lib,然后点击右面的Add JARs...选择你的驱动,点击OK
-
快速排序
2012-06-18 06:42:54
public class test1 {
int[] numArr;
int max;
int no=0;
test1( int len)
{
max=len;
numArr=new int[len];
no=0;
}
void insert(int value)
{
if(no<max)
{
numArr[no]=value;
no++;
}
}
void sort()
{
quicksort(0,no-1);
}
void quicksort(int left, int right)
{
if(left<right)
{
int mid;
//System.out.println(right);
mid=findposition(left, right);
quicksort(left, mid-1);
quicksort(mid+1, right);
}
}
int findposition(int left, int right)
{
int i;
for(i=left+1;i<=right;i++)
{
if(numArr[i]<numArr[left])
{
int temp;
temp=numArr[i];
for(int n=left;n<i;n++)
{numArr[n+1]=numArr[n];}
numArr[left]=temp;
left++;
}
}
return left;
}
void display()
{
for(int i=0;i<no;i++)
{System.out.println(numArr[i]);}
}public static void main(String[] args) {
// TODO Auto-generated method stub
test1 test = new test1(10);
test.insert(1);
test.insert(12);
test.insert(3);
test.insert(4);
test.insert(3);
test.sort();
test.display();
}
} -
划分
2012-06-17 16:15:22
public class test1 {
static int numArr[]={1,2,15,29,3,4,12,5,9};;
static void dispaly()
{
for(int i=0; i<numArr.length;i++)
{
System.out.println(numArr[i]);
}
}
public static void pattitionIt(int value)
{
int j=numArr.length-1;
for(int i=0;i<numArr.length;i++){
if(value<numArr[i])
{
swap(i, j);
i--;
j--;
}
if(i>=j) break;
}
}public static void swap(int dex1, int dex2) //swap two elements
{
int temp;
temp=numArr[dex1];
numArr[dex1]=numArr[dex2];
numArr[dex2]=temp;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
pattitionIt(9);
dispaly();
}
} -
希尔排序
2012-06-16 10:25:28
public class test1 {
static long numArr[]={1,2,15,29,3,4,12,5,9};;
static void sort( )
{
int i,j,n;
int len;
len=numArr.length;
n=1;
long temp;
while(n<=(len/3))
n=n*3+1;
while(n>0)
{
for(i=n;i<len;i++)
{
temp=numArr[i];
j=i;
while(j>n-1 && numArr[j-n]<=temp)
{
numArr[j]=numArr[j-n];
j=j-n;
}
numArr[j]=temp;
}
n=(n-1)/3;
}
}
static void dispaly()
{
for(int i=0; i<numArr.length;i++)
{
System.out.println(numArr[i]);
}
}public static void main(String[] args) {
// TODO Auto-generated method stub
sort();
dispaly();
}
} -
归并排序
2012-06-13 21:27:16
public class test1 {
static int numArr[];
//二分法查找
static void merge(int a[], int b[] )
{
int alength = a.length;
int blength= b.length;
int c[]= new int[blength+alength];
int no;
int a1=0,b1=0;
if(alength> blength)
{
no=blength;
}
else
{no=alength;}
for(int i=0; i<c.length;i++)
{
if((a1<alength) && (b1<blength))
{
if(a[a1]>=b[b1])
{c[i]=b[b1]; b1++;}
else
{c[i]=a[a1]; a1++;}
}
else{
if(a1<alength){
c[i]=a[a1]; a1++;
}
if(b1<blength){
c[i]=b[b1]; b1++;
}
}
}
for(int i=0; i<c.length;i++)
{
System.out.println(c[i]);
}
}public static void main(String[] args) {
// TODO Auto-generated method stub
numArr= new int[9];
int[] a={2,5,9};
int[] b={1,2,15,29};
merge( a, b);
}
} -
汉诺塔
2012-06-13 20:50:31
public class test1 {
static int numArr[];
//二分法查找
static void move(int value,char from, char iner, char to )
{
if(value==1)
{
System.out.println("move plane from 1" + from + " to "+to);
}
else
{
move( value-1, from,to, iner );
System.out.println("move plane from "+value + from + " to "+to);
move( value-1, iner,from,to );
}
}public static void main(String[] args) {
// TODO Auto-generated method stub
numArr= new int[9];
move(3,'a', 'b', 'c' );
}
} -
二分法查找
2012-06-12 22:39:23
public class test1 {
static int numArr[];
//二分法查找
static int find(int value)
{
int size = numArr.length;
int mid, right, left;
left=0;
right=size-1;
//value 最小
if(value<numArr[0]) return size;
//value 最大
if(value>numArr[right]) return size;
//鉴于之间
while(true)
{
mid=(left+right)/2;
if(value==numArr[mid]) return mid;
else if(left ==right) return size;
else if(value>numArr[mid] )
{
left=mid+1;
}
else{
right=mid-1;
}
}
}public static void main(String[] args) {
// TODO Auto-generated method stub
numArr= new int[9];
for(int i=0; i<9;i++)
{
numArr[i]=i;
}
System.out.print(find(4));
}
} -
阶乘
2012-06-11 14:48:58
public class test {/**
* @param args
*/
public static int sum=0;
public static int factorial(int n)
{
if(n==0){
n=1;
}else{
n=n*factorial( n-1);
}
System.out.println(n);
return n;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int s=factorial(10);
System.out.println(s);}} -
三角数字
2012-06-11 14:38:35
public class test {/**
* @param args
*/
public static int sum=0;
public static int triangleadd(int n)
{
if(n>0){
n=n+triangleadd( n-1);
}
System.out.println(n);
return n;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int s=triangleadd(10);
System.out.println(s);}
}
-
双向链表
2012-06-10 21:58:19
public class test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
TwoLinkList test =new TwoLinkList();
Link a1= new Link ("a1",1);
test.inserthead(a1);
test.deleteHead();
Link a2= new Link ("a2", 14);
test.inserthead(a2);
Link a3= new Link ("a3", 12);
test.inserthead(a3);
Link a4= new Link ("a4", 3);
test.inserthead(a4);
Link a5= new Link ("a5", 23);
test.inserthead(a5);
Link a6= new Link ("a56", 213);
test.inserthead(a6);test.deleteHead();
test.displayNext();
test.displayback();}}class Link{
String name;
int age;
Link next;
Link back;
Link(String name, int age)
{
this.name=name;
this.age=age;
}
void displayLink(){
System.out.println("my name is "+name+",my age is "+age);
}
}class TwoLinkList{
Link first;
Link last;
void inserthead(Link node){
if(first==null){
first=node;
last=first;
last.next=first;
//first.back=last;}
else{
first.next=node;
node.back=first;
first=first.next;
}
}
void displayNext()
{
Link temp=last;
while(temp!=null)
{
temp.displayLink();
temp=temp.next;
}
}
void displayback()
{
Link temp=first;
while(temp!=null)
{
temp.displayLink();
temp=temp.back;
}
}
Link deleteHead()
{
Link temp;
temp=first;
if(first==null)
{System.out.println("the list is null");}
else if(first.back==null)
{temp=first; first=null;}
else if(first.back==null){
first=null;
last=null;
}
else{
first.back.next=null;
first=first.back;
first.next=null;
}
return temp;
}
} -
shuangxiang tuilie
2012-06-03 21:33:43
public class node {/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stubDBLinkList
DBLinkList test = new DBLinkList();
test.insertFirst(new link(1,2));
test.insertFirst(new link(2,2));
test.insertlast( new link(10,2));
test.insertFirst(new link(3,2));
//test.display();
test.deletefirstlink();
test.deletefirstlink();
test.display();
}}
class link{
float iData;
float dData;
link next;
link(float i, float d)
{
iData = i;
dData=d;
}
void display(){
System.out.println("iData is "+iData+"dData is "+dData);
}
}
class DBLinkList{
link first,last;
void insertFirst(link node){
if(first==null)
{
last=node;
}
node.next=first;
first=node;
}
void insertlast(link node){
if(first==null)
{
first=node;
}
last.next=node;
last=node;
}
void deletefirstlink()
{
first=first.next;
}
void display(){
link current;
current=first;
while(current!=null)
{current.display();
current=current.next;}
}
} -
单链表
2012-05-31 21:31:56
public class node {/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
linkList test = new linkList();
test.insertLink(1,1);
test.insertLink(2,1);
test.insertLink(3,1);
test.insertLink(4,1);
test.insertLink(5,1);
test.insertLink(6,1);
test.display();
test.deleteLink();
test.deleteLink();
test.find(2);
test.deleteLink(2);
test.display();}
}
class link{
public int iData;
public float dData;
public link next;
link(int i,float d)
{
iData=i;
dData=d;
}
void display()
{
System.out.println("整数位"+iData+"fload为"+dData);
}
}
class linkList{
public link first;
linkList()
{
first=null;
}
boolean isEmpty()
{
return first==null;
}
void insertLink(int i, float d){
link temp=new link(i,d);
temp.next=first;
first=temp;
}
link deleteLink()
{
link temp=first;
first=first.next;
return temp;
}
void find(int idata)
{
link temp=first;
while(temp!=null){
if(temp.iData==idata)
{
System.out.println("find value"+idata);
temp=temp.next;
break;
}
temp=temp.next;
}
}
link deleteLink(int idata)
{
link current=first;
link privious=first;
while(current.iData!=idata)
{
if(current.next==null) current =null;
else
{
privious=current;
current=current.next;
}
}
if(current==first)
{first=first.next;}
else
{privious.next=current.next;}
return current;
}
void display()
{
link temp=first;
while(temp!=null)
{temp.display();
temp=temp.next;
}
}
} -
优先队列
2012-05-29 21:42:06
package xiti;
import java.applet.*;
import java.util.Random;
class ti2 extends Applet {
ti2()
{
queue test = new queue(10);
test.insert(2);
test.insert(21);
test.insert(12);
test.insert(3);
test.insert(22);
test.insert(9);
test.insert(23);
test.dispaly();
}}
class queue{
private int[] arr;
private int num;
private int maxSize;
queue(int len)
{
arr= new int[len];
num=0;
maxSize=len;
}
void insert(int value)
{
int i;
if(num==0)
{arr[num++]=value;
}
else
{
for(i=num;i>0;i--)
{
if(value>arr[i-1])
arr[i]=arr[i-1];
else
break;
}
arr[i]=value;
num++;
}
}
void dispaly()
{
for(int i=0;i<maxSize;i++)
{
System.out.println(arr[i]);
}
}
int remove()
{
return arr[num--];
}
int peak()
{
return arr[num-1];
}
Boolean isEmpty()
{return num==0;}
Boolean isFull()
{return num==maxSize;}
} -
队列·
2012-05-28 22:51:35
package xiti;
import java.applet.*;
import java.util.Random;
class ti2 extends Applet {
ti2()
{
queue test = new queue(4);
test.insert(4);
test.insert(41);
test.insert(24);
test.insert(34);
test.insert(54);
test.insert(9);
test.display();
test.delete();
test.delete();
test.delete();
test.display();
}}
class queue{
private int[] arr;
private int head;
private int rear;
private int num;
private int maxSize;
queue(int len)
{
arr =new int[len];
head =0;
rear=-1;
num=0;
maxSize=len;
}void insert(int value)
{
if(maxSize==rear+1) rear=-1;
arr[++rear]=value;
num++;
}
int delete()
{
int temp=arr[head++];
num--;
if(head==maxSize)
head=0;
return temp;
}
int peak()
{
return arr[head];
}
Boolean isEmpry()
{
return num==0;
}
Boolean isFull()
{return num==maxSize;}
int size(){return num;}
} -
对象排序
2012-05-27 22:41:34
package xiti;
import java.applet.*;
import java.util.Random;
class ti2 extends Applet {
ti2()
{
ObjectSort test = new ObjectSort(10);
person p1=new person();
p1.firstName="adf";
test.insert(p1);
person p2=new person();
p2.firstName="zadf";
test.insert(p2);
person p3=new person();
p3.firstName="fdf";
test.insert(p3);
test.sort();
test.dispaly();
}}
class person{
String firstName;
String lastName;
int age;
void setFirstName(String fn)
{
firstName=fn;
}
String getFirstName()
{
return firstName;
}
}class ObjectSort{
person[] arr;
int no;
ObjectSort(int len)
{
arr = new person[len];
no=0;
}
void insert(person p1)
{
arr[no]=p1;
no++;
}
void dispaly()
{
for(int i=0;i<no;i++)
{
System.out.println(arr[i].firstName+arr[i].lastName+arr[i].age);
}
}
void sort()
{
int j;
person temp;
for(int i=0; i<no-1;i++)
{
j=i;
temp=arr[i+1];
while((j>0)&& (arr[j].firstName.compareTo(temp.firstName)>0)){
arr[j+1]=arr[j];
--j;
}
arr[j+1]=temp;
}
}
} -
java 栈
2012-05-27 21:46:20
package xiti;
import java.applet.*;
import java.util.Random;
class ti2 extends Applet {
ti2()
{
Stack test= new Stack(20);
test.isEmpty();
test.push(3);
test.push(2);
test.push(5);
test.peak();
test.pop();
test.isEmpty();
}}
class Stack{
private int[] nums;
private int max;
private int top;
Stack( int len){
nums= new int[len];
top=-1;
max=len-1;
}
void push(int value)
{
nums[++top]= value;
}
int pop()
{
return nums[top--];
}
Boolean isEmpty()
{
return (top==-1);
}
Boolean isFull()
{
return (top==max);
}
int peak()
{
return nums[top];
}
} -
插入排序
2012-05-27 12:49:41
package xiti;
import java.applet.*;
import java.util.Random;
class ti2 extends Applet {
ti2()
{
insertOrder test= new insertOrder(20);
test.insert(4);
test.insert(5);
test.insert(-8);
test.insert(-18);
test.insert(8);
test.order();
test.display();
}}
class insertOrder{
int[] nums;
int no;
insertOrder( int len){
nums= new int[len];
no=0;
}
void insert(int value)
{
nums[no]= value;
no++;
}
void order()
{
int temp;
int j;
for(int i=0;i<no-1;i++)
{
temp=nums[i+1];
j=i;
while((j>=0) && (nums[j]>temp))
{
nums[j+1]=nums[j];
--j;
}
nums[j+1]=temp;
}
}
void display()
{
for (int i=0;i<no;i++)
{
System.out.println(nums[i]);
}
}
} -
选择排序
2012-05-27 09:37:25
package xiti;
import java.applet.*;
import java.util.Random;
class ti2 extends Applet {
ti2()
{
selectOrder test= new selectOrder(20);
test.insert(4);
test.insert(5);
test.insert(-8);
test.insert(-18);
test.insert(8);
test.sort();
test.dispaly();
}}
class selectOrder{
int[] nums;
int no;
selectOrder(int len){
nums= new int[len];
no=0;
}
void insert(int value)
{
nums[no]=value;
no++;
}
void delete(int value)
{
int sign=no+2;
for(int i=0; i<no;i++)
{
if(nums[i]==value){
sign=i;
}
}
if(sign<no)
{
System.out.print("find the deleted value");
for(int j=sign;j<no;j++)
{nums[j]=nums[j+1];no--;}
}
else
{System.out.print("can not find the delete value");}
}
void dispaly()
{for(int i=0; i<no;i++)
{
System.out.println(nums[i]+"^^^^^^^^");
}
}
void sort()
{
int min;
for(int i=0;i<no;i++)
{
for(int j=i+1;j<no;j++)
{
min=nums[i];
if(min>nums[j])
{
min=nums[j];
nums[j]=nums[i];
nums[i]=min;
}
}
}
}}
标题搜索
我的存档
数据统计
- 访问量: 87122
- 日志数: 201
- 图片数: 1
- 书签数: 8
- 建立时间: 2008-10-31
- 更新时间: 2012-10-08