gulu工具地址:http://100continue.iteye.com/blog/1821207
github地址:https://github.com/100Continue/Gulu--web-server-test-tools
准备:
1.maven环境:http://jingyan.baidu.com/article/295430f136e8e00c7e0050b9.html
2.java(JDK):http://jingyan.baidu.com/article/bea41d435bc695b4c41be648.html
3.开发工具:eclipse
4.下载Gulu
进行开发直接上代码:
1.往百度发起一个GET请求:
@Test
public void test01() throws Exception{
Response r = new GetRequest().doRequest("https://www.baidu.com/");
// System.out.println("请求返回值:"+r.getResponseBodyAsString());
// System.out.println("请求返回状态码:"+r.getStatusCode());
AssertStringBody.assertStatusCode(r, 200);
AssertStringBody.assertBody(r, "www.baidu.com/more/");
}
2.往百度发起一个POST请求:
@Test
public void test01() throws Exception{
StringBodyEntity stringBody = new StringBodyEntity("wd=111");
Response r = new PostRequest().doRequest("https://www.baidu.com/",stringBody);
// System.out.println("请求返回值:"+r.getResponseBodyAsString());
// System.out.println("请求返回状态码:"+r.getStatusCode());
AssertStringBody.assertStatusCode(r, 302);
// AssertStringBody.assertBodyEQ(r, "www.baidu.com/more/");
}
总结:第一次撸视频,效果有点不理想。有些东西没有考虑到,比如要准备一个接口供调用。希望下次改进!下次还是围绕这个工具开讲,你们的赞赏是我的动力,动动动!
视频: