国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

Java跨session實現(xiàn)token接口測試過程圖解

瀏覽:90日期:2022-09-03 11:48:25

這套框架的報告是自己封裝的

一般token會在登錄接口返回結果中呈現(xiàn),從代碼層面獲取token的方式有很多種,我是使用jsonpath這個json路徑語言去匹配token所在路徑的key值

Java跨session實現(xiàn)token接口測試過程圖解

Java跨session實現(xiàn)token接口測試過程圖解

沒有使用testng.xml的情況下調(diào)試testCase,需要設置一下dependsOnMethods,否則token將無法傳遞給其他test步驟

附上TestUtil.getToken()方法:

//獲取返回的token ,使用JsonPath獲取json路徑 public static HashMap<String,String> getToken(CloseableHttpResponse closeableHttpResponse,String jsonPath) throws Exception{ HashMap<String,String> responseToken = new HashMap<String, String>(); String responseString = EntityUtils.toString( closeableHttpResponse.getEntity(),'UTF-8'); ReadContext ctx = JsonPath.parse(responseString); String Token = ctx.read(jsonPath); //'$.EFPV3AuthenticationResult.Token' if(null == Token||''.equals(Token)){ new Exception('token不存在'); } responseToken.put('x-ba-token',Token); return responseToken; }

maven地址

<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-client --><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-client</artifactId><version>7.6.1</version></dependency>

接口測試神器:https://github.com/wiztools/rest-client

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Java
相關文章:
主站蜘蛛池模板: 呼图壁县| 黄龙县| 伊通| 昭通市| 宁城县| 静海县| 耒阳市| 云安县| 宁阳县| 兴化市| 宜昌市| 平遥县| 巴塘县| 行唐县| 溧阳市| 上饶县| 聂荣县| 英吉沙县| 南康市| 班戈县| 万盛区| 旅游| 周口市| 濮阳县| 梧州市| 巨野县| 连江县| 图们市| 慈溪市| 积石山| 六枝特区| 潼关县| 内黄县| 阜南县| 兴文县| 永丰县| 岑溪市| 遂平县| 景德镇市| 朝阳县| 武夷山市|