背景:调用Eolinker接口,统计接口测试用例的完成情况,并写入excel文件;
1、调用登录接口,JSON提取器提取接口返回的accessToken,再封装到HTTP信息头管理器中;
2、请求工作空间列表接口,JSON提取器提取第7个空间项目的spaceKey;
3、请求项目列表接口,JSON提取器提取projectHashKey、projectName所有值;
4、ForEach控制器循环projectHashKey值的次数;
5、请求统计分析接口,使用计数器每次+1,获取到对应的项目projectName_X,这里的projectName_X对应第3步的projectName列表中值;
6、JSON提取器提取接口返回值,beanshell后置处理程序将返回值写入excel文件;
javascript
FileWriter fstream = new FileWriter("D:\\workspace\\script\\statistics.csv",true);
BufferedWriter out=new BufferedWriter(fstream);
i=vars.get("count");
out.write(vars.get("projectName_"+i)+","+"API总数"+","+vars.get("apiCount")+","+"已覆盖测试用例API数"+","+vars.get("hasCaseCount")+","+"未覆盖测试用例API数"+","+vars.get("noCaseCount")+","+"测试用例数"+","+vars.get("caseCount")+","+"实现自动化API数"+","+vars.get("hasSceneCount")+","+"未实现自动化API数"+","+vars.get("noSceneCount")+"\n");
//out.write(vars.get("projectName_"+i)+","+vars.get("apiCount")+","+vars.get("hasCaseCount")+","+vars.get("noCaseCount")+","+vars.get("caseCount")+","+vars.get("hasSceneCount")+","+vars.get("noSceneCount")+"\n");
out.close();
fstream.close();