TA的每日心情 | 开心 2017-7-11 14:07 |
---|
签到天数: 8 天 连续签到: 1 天 [LV.3]测试连长
|
描述:这是一个接口压力测试,调用JAVA编写的一个函数,对返回值进行校验,代码如下:
import lrapi.lr;
import com.lr.test.*;
public class Actions
{
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
String email ="<email>";
String address_url ="http://192.168.1.12:8080/interface/index.php/v1/fun?email="+email+";
String result = "";
lr.rendezvous("ReadGO");
lr.start_transaction("FUN");
lr.start_sub_transaction("A","FUN");
lr.start_sub_transaction("B","FUN");
lr.start_sub_transaction("C","FUN");
result = test.getHttpByUrl(address_url);
//结果A
if(!test.getString(result,"NUM").equals("12") && test.getString(result,"Letter").equals("A"))
{
lr.end_transaction("FUN", lr.PASS);
lr.end_sub_transaction("A", lr.PASS);
lr.end_sub_transaction("C", lr.FAIL);
lr.end_sub_transaction("B",lr.FAIL);
lr.error_message(email);
/结果B
}
else if (test.getString(result,"NUM").equals("12") && test.getString(result,"Letter").equals("A"))
{
lr.end_transaction("FUN", lr.PASS);
lr.end_sub_transaction("A", lr.FAIL);
lr.end_sub_transaction("B",lr.PASS);
lr.end_sub_transaction("C", lr.FAIL);
lr.error_message(email);
//结果C
}
else if(test.getString(result,"Letter").equals("C"))
{
lr.end_transaction("FUN", lr.PASS);
lr.end_sub_transaction("A", lr.FAIL);
lr.end_sub_transaction("B",lr.FAIL);
lr.end_sub_transaction("C", lr.PASS);
lr.error_message(email);
}
else
{
lr.error_message(result);
lr.end_transaction("FUN", lr.FAIL);
lr.end_sub_transaction("A", lr.FAIL);
lr.end_sub_transaction("B",lr.FAIL);
lr.end_sub_transaction("C", lr.FAIL);
}
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
问题:
1、如果压力只执行一次(Run until completion),通过事物数和打印email个数一致;如果压力持续执行几分钟,打印email个数会大于通过的事物数,这是怎么回事?
2、一般压力测试只执行一次(Run until completion),还是持续执行一段时间呢?
3、对于我的代码,这样做是否合适呢,有其他更好的方法吗?
4、有跳过前端直接测试Redis处理能力的思路、方法或者例子吗?
|
|