单元测试增加assert

This commit is contained in:
hellozrh 2023-01-18 14:35:18 +08:00
parent 7c0a8a4571
commit 9ceac4d3cd

View File

@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.cell.CellLocation;
import cn.hutool.poi.excel.sax.handler.RowHandler;
import org.apache.poi.ss.usermodel.CellStyle;
import org.junit.Assert;
import org.junit.Test;
@ -75,16 +76,24 @@ public class ExcelUtilTest {
@Test
public void doAfterAllAnalysedTest() {
String path = "readBySax.xls";
AtomicInteger doAfterAllAnalysedTime = new AtomicInteger(0);
try{
ExcelUtil.readBySax(path, -1, new RowHandler() {
@Override
public void handle(int sheetIndex, long rowIndex, List<Object> rowCells) {
System.out.println(StrUtil.format("sheetIndex={};rowIndex={},rowCells={}",sheetIndex,rowIndex,rowCells));
}
@Override
public void doAfterAllAnalysed() {
doAfterAllAnalysedTime.addAndGet(1);
}
});
}catch (Exception ex){
ex.printStackTrace();
}
//总共2个sheet页读取所有sheet时一共执行doAfterAllAnalysed2次
Assert.assertEquals(2, doAfterAllAnalysedTime.intValue());
}
}