winrunner怎么生成日志文件?
1、简单代码如下,用winrunner的命令行自动执行测试的话,执行完成关闭winrunner连带测试结果也一起关闭了,想看结果的话还要打开winrunner,那跟不用命令行相差不多,大家是怎么看测试结果?2、winrunner有自带的日志文件吗?
3、如果要将测试的结果保存在一指定位置的log文件中(txt文件也可以),winrunner怎么实现?
以上3个目的都一样,就是怎么在不打开winrunner软件的情况下查看测试结果。最好能包括下图中红色方框中的信息。
# 连接数据库-查询-导出文件
#
if(db_connect ("query1","DSN=test_sql;Description=数据库测试;UID=sa;PWD=11;APP=WinRunner;WSID=WWW-B82C2FBDDB9;DATABASE=htf_test",30)==E_OK)
report_msg("数据库连接成功");
else
report_msg("数据库连接失败");
if(db_execute_query ("query1","SELECT * FROM vip_new_lw",num)==E_OK)
report_msg("数据查询成功");
else
report_msg("数据查询失败");
if(db_write_records ("query1","E:\\11.txt",TRUE,5)==E_OK)
report_msg("数据导出成功");
else
report_msg("数据导出失败");
# 比较文件 E:\\11.txt和E:\\12.txt
if(file_compare("E:\\11.txt","E:\\12.txt","save")==E_OK)
report_msg("数据相同");
else
report_msg("数据不同"); C:\Program Files\Mercury Interactive\WinRunner\tmp\noname9\res1\report.txt就是你所需要的结果报告
"C:\Program Files\Mercury Interactive\WinRunner\tmp\noname9"为你脚本所在目录 没有Report.txt文件啊?有个Report的文件夹,里面的Results文件看不明白,想要个直观点的,自己生成也可以~
winrunner里有设置可以导出日志吗?
[ 本帖最后由 84690267 于 2009-2-24 10:25 编辑 ] 可以了,现在用的下面的代码:
#
# 连接数据库-查询-导出文件
#
if(db_connect ("query1","DSN=test_sql;Description=数据库测试;UID=sa;PWD=11;APP=WinRunner;WSID=WWW-B82C2FBDDB9;DATABASE=htf_test",30)==E_OK)
{report_msg("数据库连接成功");
MSG = time_str(get_time());
Result = "e:\\13.txt";
file_open(Result,2);
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据库连接成功 \r\n",MSG,i);#write data in txt file
}
else
{report_msg("数据库连接失败");
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据库连接失败 \r\n",MSG,i);#write data in txt file
}
#######################################################
if(db_execute_query ("query1","SELECT * FROM vip_new_lw",num)==E_OK)
{report_msg("数据查询成功");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据查询成功 \r\n",MSG,i);#write data in txt file
}
else
{report_msg("数据查询失败");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据查询失败 \r\n",MSG,i);#write data in txt file
}
if(db_write_records ("query1","E:\\11.txt",TRUE,5)==E_OK)
{report_msg("数据导出成功");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据导出成功 \r\n",MSG,i);#write data in txt file
}
else
{report_msg("数据导出失败");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据导出失败 \r\n",MSG,i);#write data in txt file
}
# 比较文件 E:\\11.txt和E:\\12.txt
#
if(file_compare("E:\\11.txt","E:\\12.txt","save")==E_OK)
{report_msg("数据相同");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据相同 \r\n",MSG,i);#write data in txt file
file_printf(Result,"%d-------------------------------------------------------------\r\n",MSG,i);
file_close(Result);
}
else
{report_msg("数据不同");
MSG = time_str(get_time());
Result = "e:\\13.txt";
db_write_records("13","e:\\13.txt",TRUE,NO_LIMIT);
file_printf(Result,"%s : %d 数据不同 \r\n",MSG,i);#write data in txt file
file_printf(Result,"%d-------------------------------------------------------------\r\n",i);
file_close(Result);
}
导出效果为:
Tue Feb 24 12:24:25 2009 : 0 数据库连接成功
Tue Feb 24 12:24:25 2009 : 0 数据查询成功
Tue Feb 24 12:24:25 2009 : 0 数据导出成功
Tue Feb 24 12:24:25 2009 : 0 数据不同
0-------------------------------------------------------------
Tue Feb 24 12:24:37 2009 : 0 数据库连接成功
Tue Feb 24 12:24:37 2009 : 0 数据查询成功
Tue Feb 24 12:24:37 2009 : 0 数据导出成功
Tue Feb 24 12:24:37 2009 : 0 数据不同
0-------------------------------------------------------------
Tue Feb 24 12:25:14 2009 : 0 数据库连接成功
Tue Feb 24 12:25:14 2009 : 0 数据查询成功
Tue Feb 24 12:25:14 2009 : 0 数据导出成功
Tue Feb 24 12:25:14 2009 : 0 数据相同
0------------------------------------------------------------- 不过这样代码太过繁琐了,有简单点的吗?
页:
[1]