Appium 测试报告--步骤级报告

每执行一轮我们最后都需要看对应的测试结果,以此来判断应用是否存在问题,

因为没有采用TestNG  中的断言机制,所以报告没法套用TestNg 的方式展示,需要自定义方法来记录结果

第一步先要对测试用例的每一步记录测试结果

这里需要考虑新建的Sheet 没有任何标题时程序要先自行创建标题




当有数据时我们在后面一行追加记录


整个方法对应的完整代码是

public static void Record_TestResult() {

try {

//获取文件流

FileInputStream ExcelFile1 = new FileInputStream(constant.ReportPath);

System.out.println("报告文件"+constant.ReportPath);

//创建工作本

XSSFWorkbook  ExcelWBook1 = new XSSFWorkbook(ExcelFile1);

//获取Sheet 名称

XSSFSheet ReportSheet=ExcelWBook1.getSheet("Report");

//获取测试报告的Sheet  页

XSSFRow Row;

//此处先判断下Report 的Sheet 是否有获取到

if (ReportSheet==null) {

//如果没有获取到时我们就新创建一个Sheet

ReportSheet=ExcelWBook1.createSheet("Report");

//Sheet 创那建之后再新建一个行号

XSSFRow Row2=ReportSheet.createRow(0);

//对第一行新加标题

Row2.createCell(0).setCellValue("测试用例ID");

Row2.createCell(1).setCellValue("用例描述");

Row2.createCell(2).setCellValue("测试步骤");

Row2.createCell(3).setCellValue("测试对象中文名称");

Row2.createCell(4).setCellValue("定位方式");

Row2.createCell(5).setCellValue("测试对象实体");

Row2.createCell(6).setCellValue("操作方法");

Row2.createCell(7).setCellValue("测试数据");

Row2.createCell(8).setCellValue("验证数据");

Row2.createCell(9).setCellValue("测试结际结果");

}

//获取最大行号

int LastNum2=ReportSheet.getLastRowNum();

//在最大行号后加一行用来写新的记录

Row=ReportSheet.createRow(LastNum2+1);

//获取行号信息之后将结果写入到对应的列

Row.createCell(constant.iCaseID).setCellValue(constant.sCaseID);

Row.createCell(constant.iReport_CaseDesc).setCellValue(constant.sCaseDesc);

Row.createCell(constant.iReport_CaseStep).setCellValue(constant.sCaseStep);

Row.createCell(constant.iReport_ObjectName).setCellValue(constant.sObjectName);

Row.createCell(constant.iReport_FindType).setCellValue(constant.sFindType);

Row.createCell(constant.iReport_Object).setCellValue(constant.sObject);

Row.createCell(constant.iReport_OptionMethod).setCellValue(constant.sOptionMethod);

Row.createCell(constant.iReport_TestData).setCellValue(constant.sTestData);

Row.createCell(constant.iReport_CheckVaue).setCellValue(constant.sCheckVaue);

Row.createCell(constant.iReport_TestResult).setCellValue(constant.sTestResult);

//创建文件输出流

FileOutputStream fileOut = new FileOutputStream(constant.ReportPath);

// 写入文件输出流到Excel

ExcelWBook1.write(fileOut);

//关闭文件流

fileOut.close();

//释放Excel

ExcelFile1.close();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}



执行结果展示


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 创建新工程 打开Eclipse新建一个工程 点下一步 输入名称 点完成 新建一个目录用来存在第三方库文件 选择目录...
    长新阅读 2,236评论 3 1
  • 使用首先需要了解他的工作原理 1.POI结构与常用类 (1)创建Workbook和Sheet (2)创建单元格 (...
    长城ol阅读 8,553评论 2 25
  • 测试集中报告可以看成是一个总表,这时可以用Excel 的图表工具自动生成图表,整个测试集测试通过后再统计各个级别的...
    长新阅读 2,085评论 0 1
  • 这个级别维度稍微粗一点,是统计到每一条用例的成功与失败情况,不记录具体哪一步出错,如果显示当前用例失败需要去对应了...
    长新阅读 927评论 0 1
  • IO简单概述 IO解决问题 : 解决设备与设备之间的数据传输问题(硬盘 -> 内存 内存 -> 硬盘) 读和写文...
    奋斗的老王阅读 3,457评论 0 53