所有工具只能帮组我们解决三分之一的问题,千万不要迷恋工具,否则在没有工具的时候你会无能为力
工具只是在一定的程度上提升效率。
一般来说性能测试不会像功能测试一样,要对所有功能都进行测试,只是会针对系统的核心业务进行测试
如论坛的登录和发帖两个核心功能的实现
要实现登录和发帖,需要发送post请求和多线程,获取性能指标
登录post请求:
package com.juan.load; import java.text.SimpleDateFormat; public class PhpwindPost{ private String host="moggie"; private int port =80 ; private MultiTreadedHttpConnectionManager connectionManager =new MultiTreadedHttpConnectionManager(); private HttpClient client = new HttpClient(connectionManager);
public PhpwindPost(){ client.getHostConfiguration().setHost(host,port); } public void doLogin{ PostMethod login= new PostMethod("/phpwind/login.php?"); NameValuePair step =new NameValuePair("step","2"); NameValuePair lgt = new NameValuePair("lgt","0"); NameValuePair pwuser = new NameValuePair("pwuser","denny"); NameValuePair pwwd = new NameValuePair("pwwd","123456"); login.setRequestBody(new NameValuePair[]{step,lgt,pwuser,pwwd}); try{ client.executeMethod(login); } catch (Exception e) { e.printStackTrace(); } finally{ login.releaseConnection(); }
//发帖请求 } public void doPost(int thinTime){
long startTime = System.currentTimeMillis();
PostMethod correlate = new PostMethod("/phpwind/post.php?fid=29");
String verifyCode = "";
try {
client. executeMethod(correlate);
String source = new String(correlate)
}
}
}