pom文件设置
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11-beta2</version>
</dependency><dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
其中poi-ooxml是为读取xlsx特意引入,切要和poi版本一致
代码示范
InputStream is = new FileInputStream("E://demo.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(is); //xlsx文件
HSSFWorkbook wb = new HSSFWorkbook(is); //更好的excel文件格式,如xls
XSSFSheet sheetAt = wb.getSheetAt(0); //获得第一工作页
Row row = sheetAt.getRow(0); //获得第一行
row.getCell(0).toString(); //获得第一行第一列的数据
测试框架:
- TestNG 官网:http://testng.org/doc/documentation-main.html
- REST-Assured 官网:https://github.com/jayway/rest-assured /https://github.com/jayway/rest-assured/wiki/Usage
- Mock Server官网:https://github.com/jamesdbloom/mockserver
- Mockito 官网:http://mockito.org/