为啥这边这么火 我发的贴下面评论的人都没有····~~~~~~~~~~不服
不知道生成的 @ TestCase 可用率怎么样?有效性如何?生成后需要人干预的程度高吗?
package Trigger;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import net.sf.json.JSONObject;
import org.apache.http.HeaderIterator;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.cookie.BasicClientCookie;
import org.apache.http.impl.cookie.BestMatchSpecFactory;
import org.apache.http.impl.cookie.BrowserCompatSpecFactory;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
public class httpclient {
public static CookieStore cookieStore = new BasicCookieStore();
public CloseableHttpClient httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
public static HttpClientContext context = null;
/**
* get 请求
* @param url
* @param Parameter
* @return
* @throws Exception
* @throws ClientProtocolException
*/
public JSONObject sendGet(String url, String Parameter) throws Exception {
StringBuffer responseStr=new StringBuffer();
try {
if(Parameter.isEmpty()==false){url=url + "?" + Parameter;}
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
}
System.out.println("----------------------------------------");
InputStream inSm = entity.getContent();
Scanner inScn = new Scanner(inSm,"utf-8");
while (inScn.hasNextLine()) {
responseStr.append(inScn.nextLine().toString());
}
httpget.abort();
} finally {
httpclient.getConnectionManager().shutdown();
}
System.out.println("Response:");
System.out.println("----------------------------------------");
System.out.println(responseStr.toString());
System.out.println("----------------------------------------");
return JSONObject.fromObject(responseStr.toString().trim());
}
/**
* 用 post 请求
* @param url
* @param parameter
* @return
*/
public JSONObject sendPost(String url, String parameter) {
String Response =new String();
HttpPost httpPost = new HttpPost(url);
List formParams = new ArrayList();
FormatProcessing(formParams,parameter);
UrlEncodedFormEntity urlEncodedFormEntity;
try {
urlEncodedFormEntity = new UrlEncodedFormEntity(formParams, "UTF-8");
httpPost.setEntity(urlEncodedFormEntity);
httpPost.setHeader("Content-Type","application/x-www-form-urlencoded");
System.out.println("execurting request:" + httpPost.getURI()+"\nparameter:"+parameter);
HttpResponse httpResponse = null;
httpResponse = httpclient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
if (httpEntity != null) {
String content = EntityUtils.toString(httpEntity, "UTF-8");
Response=content;
}
printResponse(httpResponse);
setContext();
setCookieStore(httpResponse);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
//关闭连接,释放资源
httpclient.getConnectionManager().shutdown();
}
System.out.println("Response:");
System.out.println("----------------------------------------");
System.out.println(Response.toString());
System.out.println("----------------------------------------");
return JSONObject.fromObject(Response.toString().trim());
}
/**
* Post 入参转换成 List
* @param formParams
* @param parameter
*/
public static void FormatProcessing (List formParams, String parameter){
try{
String value[] =parameter.split("&");
for(int i=0;i<value.length;i++){
String keyword[]=value[i].split("=");
formParams.add(new BasicNameValuePair(keyword[0], keyword[1]));
}}catch(Exception e){
e.printStackTrace();
System.out.println("入参转换失败");
}
}
/**
* 打印 httpResponse
* @param httpResponse
* @throws ParseException
* @throws IOException
*/
public static void printResponse(HttpResponse httpResponse) throws ParseException, IOException {
HttpEntity entity = httpResponse.getEntity();
System.out.println("status:" + httpResponse.getStatusLine());
HeaderIterator iterator = httpResponse.headerIterator();
while (iterator.hasNext()) {
System.out.println("\t" + iterator.next());
}
if (entity != null) {
try {
String responseString = EntityUtils.toString(entity, "UTF-8");
}catch(Exception E){}
}
}
/**
* 保留 cookie
* @param httpResponse
*/
public static void setCookieStore(HttpResponse httpResponse) {
String setCookie =new String();
if(httpResponse.getFirstHeader("Set-Cookie")!=null) {
setCookie = httpResponse.getFirstHeader("Set-Cookie").getValue();
}
String JSESSIONID =new String();
if(setCookie.isEmpty()==false) {
JSESSIONID = setCookie.substring("JSESSIONID=".length(),
setCookie.indexOf(";"));
}
// 新建一个 Cookie
BasicClientCookie cookie = new BasicClientCookie("JSESSIONID",
JSESSIONID);
cookie.setVersion(0);
cookie.setDomain("127.0.0.1");
cookie.setPath("/CwlProClient");
cookieStore.addCookie(cookie);
}
/**
* 设置 Context
*/
public static void setContext() {
context = HttpClientContext.create();
Registry registry = RegistryBuilder
. create()
.register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactory())
.register(CookieSpecs.BROWSER_COMPATIBILITY,
new BrowserCompatSpecFactory()).build();
context.setCookieSpecRegistry(registry);
context.setCookieStore(cookieStore);
}
/**
* tmain
* @param args
* @throws Exception
/
public static void main(String[] args) throws Exception {
Trigger.httpclient api=new httpclient();
String url ="http://30.17.1.73:8080/APIInterface/GetUserList";
String data="page=1&limit=3";
System.out.println("response:"+api.sendGet(url,data));
/ String url ="http://30.17.1.73:8080/APIInterface/InsertProject";
String data="name=test&remark=test&createuser=test&type=1";
System.out.println(api.sendPost(url,data));*/
}
}
非常棒
非常好的团队 非常棒的老板 推荐 @!!
顶一下 ~
帖子写的不错,但却看到最后这是硬广呀
逝者安息🙏
感谢分享
有 mac 版 过段时间开放吧
楼主想法很不错,想问下目前使用效果如何?
相对你们之前之前的一些方案效果提升多少呢?
嗯 没错
感谢楼主分享,几年前做过同样类似的事情,当然楼主显然做的比我要好,我说下我碰到的问题:
1,像这种数据驱动或者关键字驱动体系化的框架会限制测试开发同学的一些开发或架构设计能力
2,同时上层框架化的话局限性挺大,让别人看到上层的东西会感觉技术 sense 有点 low
3,其次有一些复杂场景支持不是很好
感觉要沉了
这种图 去燥加中级滤波可 处理起来没那么麻烦也可以提升识别率
总结的不错,建议楼主可以在图像领域继续深挖
tesseract 一些深度学习的东西加上它本身一些训练库 可以继续研究一下
谢谢🙏 事在人为 大家互勉
抬举了 ,写 2017 总结我自己已经写了 主要有太多心酸的事情不想公开
这个入參的类型是业务形态决定的,我们需要做的支持各种情况
如果有数组 也是按照 key:value 的方式进行入參,同 postman 理
成都 !!!
期待去参加,在想是不是可以投一稿
你被测应用是什么包 签名和证书都弄好了吗?
接口本身自带属性属于哪个 service 或者哪个业务模块 按照这个分就可以了
查数据校验看做成一个 step 就可以了 把查出来的数据包装成 json 格式 按照接口返回一样的校验。
内容挺好的,值得一去!
顶大猫!
必须的
看到这个图 我又觉得这次大会 还没开始就已经火了!
三月底有一次 欢迎关注
如果你得到一些建议
应该说明一下你自己的情况
你的困惑等等