用例编写类及用例模板文件生成类添加读取外部数据有效性方法

This commit is contained in:
彭宇琦 2020-04-01 19:13:04 +08:00
parent 3a523943de
commit 6d5348509e
17 changed files with 284 additions and 76 deletions

View File

@ -26,7 +26,7 @@
</datas>
<datas id='模块'>
<file path='F:\5.测试文件\1.用例生成程序测试文件\模块信息.xlsx' sheet='sheet1' column='2' start_row='2' end_row='11' />
<file path='Test/ListDataFile/模块信息.xlsx' regex='Sheet1' column='2' start_row='2' end_row='11' />
</datas>
</sheet>

Binary file not shown.

View File

@ -0,0 +1,17 @@
ç¬?模å<C2A1>—,呵呵,,ç¬?4模å<C2A1>—,ç¬?0模å<C2A1>—,
ç¬?模å<C2A1>—,ç¬?4模å<C2A1>—,,ç¬?5模å<C2A1>—,ç¬?1模å<C2A1>—,ç¬?3模å<C2A1>
ç¬?模å<C2A1>—,ç¬?5模å<C2A1>—,ç¬?5模å<C2A1>—,ç¬?6模å<C2A1>—,ç¬?2模å<C2A1>—,ç¬?4模å<C2A1>
ç¬?模å<C2A1>—,ç¬?6模å<C2A1>—,ç¬?6模å<C2A1>—,ç¬?7模å<C2A1>—,ç¬?3模å<C2A1>—,ç¬?5模å<C2A1>
ç¬?模å<C2A1>—,ç¬?7模å<C2A1>—,ç¬?7模å<C2A1>—,ç¬?8模å<C2A1>—,ç¬?4模å<C2A1>—,ç¬?6模å<C2A1>
ç¬?模å<C2A1>—,ç¬?8模å<C2A1>—,ç¬?8模å<C2A1>—,ç¬?9模å<C2A1>—,ç¬?5模å<C2A1>—,ç¬?7模å<C2A1>
ç¬?模å<C2A1>—,ç¬?9模å<C2A1>—,ç¬?9模å<C2A1>—,ç¬?0模å<C2A1>—,ç¬?6模å<C2A1>—,ç¬?8模å<C2A1>
ç¬?模å<C2A1>—,ç¬?0模å<C2A1>—,ç¬?0模å<C2A1>—,ç¬?1模å<C2A1>—,ç¬?7模å<C2A1>—,ç¬?9模å<C2A1>
ç¬?模å<C2A1>—,ç¬?1模å<C2A1>—,ç¬?1模å<C2A1>—,ç¬?2模å<C2A1>—,ç¬?8模å<C2A1>—,ç¬?0模å<C2A1>
ç¬?0模å<C2A1>—,ç¬?2模å<C2A1>—,ç¬?2模å<C2A1>—,ç¬?3模å<C2A1>—,ç¬?9模å<C2A1>—,ç¬?1模å<C2A1>
ç¬?1模å<C2A1>—,ç¬?3模å<C2A1>—,ç¬?3模å<C2A1>—,ç¬?4模å<C2A1>—,,ç¬?2模å<C2A1>
ç¬?2模å<C2A1>—,,哈哈,ç¬?5模å<C2A1>—,,ç¬?3模å<C2A1>
ç¬?3模å<C2A1>—,,,ç¬?6模å<C2A1>—,,ç¬?4模å<C2A1>
,,,ç¬?7模å<C2A1>—,,ç¬?5模å<C2A1>
,,,ç¬?8模å<C2A1>—,ç¬?0模å<C2A1>—,ç¬?6模å<C2A1>
,,,ç¬?9模å<C2A1>—,ç¬?1模å<C2A1>—,ç¬?7模å<C2A1>
,,,咯咯,ç¬?2模å<C2A1>—,
1 �模� 呵呵 �4模� �0模�
2 �模� �4模� �5模� �1模� �3模�
3 �模� �5模� �5模� �6模� �2模� �4模�
4 �模� �6模� �6模� �7模� �3模� �5模�
5 �模� �7模� �7模� �8模� �4模� �6模�
6 �模� �8模� �8模� �9模� �5模� �7模�
7 �模� �9模� �9模� �0模� �6模� �8模�
8 �模� �0模� �0模� �1模� �7模� �9模�
9 �模� �1模� �1模� �2模� �8模� �0模�
10 �0模� �2模� �2模� �3模� �9模� �1模�
11 �1模� �3模� �3模� �4模� �2模�
12 �2模� 哈哈 �5模� �3模�
13 �3模� �6模� �4模�
14 �7模� �5模�
15 �8模� �0模� �6模�
16 �9模� �1模� �7模�
17 咯咯 �2模�

View File

@ -0,0 +1,17 @@
第1模块 呵呵 第34模块 第50模块
第2模块 第14模块 第35模块 第51模块
第3模块 第15模块 第25模块 第36模块 第52模块
第4模块 第16模块 第26模块 第37模块 第53模块
第5模块 第17模块 第27模块 第38模块 第54模块
第6模块 第18模块 第28模块 第39模块 第55模块
第7模块 第19模块 第29模块 第40模块 第56模块
第8模块 第20模块 第30模块 第41模块 第57模块
第9模块 第21模块 第31模块 第42模块 第58模块
第10模块 第22模块 第32模块 第43模块 第59模块
第11模块 第23模块 第33模块 第44模块
第12模块 哈哈 第45模块
第13模块 第46模块
第47模块
第48模块 第60模块
第49模块 第61模块
咯咯 第62模块

Binary file not shown.

View File

@ -39,9 +39,41 @@ import pres.auxiliary.tool.file.UnsupportedFileException;
*/
public class ListFileRead {
/**
* 存储文件的后缀名
* 切分标记tap
*/
private String suffix = "";
public static final String SPLIT_TAB = "\\t";
/**
* 切分标记空格
*/
public static final String SPLIT_SPACE = " ";
/**
* 切分标记中文逗号
*/
public static final String SPLIT_COMMA_CH = "";
/**
* 切分标记英文逗号
*/
public static final String SPLIT_COMMA_EN = ",";
/**
* 切分标记中文分号
*/
public static final String SPLIT_SEMICOLON_CH = "";
/**
* 切分标记英文分号
*/
public static final String SPLIT_SEMICOLON_EN = ";";
/**
* 切分标记中文顿号
*/
public static final String SPLIT_STOP_CH = "";
/**
* 切分标记斜杠
*/
public static final String SPLIT_SLASH = "/";
/**
* 切分标记反斜杠
*/
public static final String SPLIT_BACKSLASH = "\\\\";
/**
* 存储被切分的词语<br>
@ -50,11 +82,6 @@ public class ListFileRead {
*/
private ArrayList<ArrayList<String>> wordList = new ArrayList<ArrayList<String>>();
/**
* 存储对文本分词处理的分隔符
*/
private String splitWord = "";
/**
* 存储当前获取到的内容组成的表格最大行数
*/
@ -86,10 +113,15 @@ public class ListFileRead {
* @throws IOException 文件状态或路径不正确时抛出的异常
*/
public ListFileRead(File file, String regex) throws IOException {
//若regex为null则赋为空
if (regex == null) {
regex = "";
}
// 存储文件的名称
String fileName = file.getName();
//存储文件名的后缀并根据后缀来判断采用哪一种读取方式
switch ((suffix = fileName.substring(fileName.lastIndexOf(".") + 1))) {
switch ( fileName.substring(fileName.lastIndexOf(".") + 1)) {
case "doc":
case "docx":
readWord(file, regex);
@ -134,13 +166,13 @@ public class ListFileRead {
* @return 相应的数据
*/
public List<String> getColumn(int columnIndex, int startRowIndex, int endRowIndex) {
columnIndex = columnIndex >= maxColumnNum ? maxColumnNum : columnIndex;
columnIndex = columnIndex >= maxColumnNum ? maxColumnNum - 1 : columnIndex;
columnIndex = columnIndex < 0 ? 0 : columnIndex;
//若传值大于最大maxRowNum时则直接赋予maxRowNum
startRowIndex = (startRowIndex > maxRowNum) ? maxRowNum : startRowIndex;
startRowIndex = (startRowIndex >= maxRowNum) ? maxRowNum - 1 : startRowIndex;
startRowIndex = startRowIndex < 0 ? 0 : startRowIndex;
endRowIndex = (endRowIndex > maxRowNum) ? maxRowNum : endRowIndex;
endRowIndex = (endRowIndex >= maxRowNum) ? maxRowNum - 1 : endRowIndex;
endRowIndex = endRowIndex < 0 ? 0 : endRowIndex;
//若两个传值相同则endRowIndex+1
@ -150,9 +182,9 @@ public class ListFileRead {
ArrayList<String> texts = new ArrayList<>();
int minRowIndex = startRowIndex < endRowIndex ? startRowIndex : endRowIndex;
int maxRowIndex = startRowIndex < endRowIndex ? endRowIndex : endRowIndex;
int maxRowIndex = startRowIndex < endRowIndex ? endRowIndex : startRowIndex;
//获取数据
for (int rowIndex = startRowIndex; rowIndex < endRowIndex; rowIndex++) {
for (int rowIndex = minRowIndex; rowIndex < maxRowIndex; rowIndex++) {
texts.add(wordList.get(columnIndex).get(rowIndex));
}
@ -180,15 +212,15 @@ public class ListFileRead {
ArrayList<ArrayList<String>> newWordList = new ArrayList<>();
//若传值大于最大maxColumnNum时则直接赋予maxColumnNum小于0则直接赋予0
startColumnIndex = startColumnIndex >= maxColumnNum ? maxColumnNum : startColumnIndex;
startColumnIndex = startColumnIndex >= maxColumnNum ? maxColumnNum - 1 : startColumnIndex;
startColumnIndex = startColumnIndex < 0 ? 0 : startColumnIndex;
endColumnIndex = endColumnIndex >= maxColumnNum ? maxColumnNum : endColumnIndex;
endColumnIndex = endColumnIndex >= maxColumnNum ? maxColumnNum - 1 : endColumnIndex;
endColumnIndex = endColumnIndex < 0 ? 0 : endColumnIndex;
//若传值大于最大maxRowNum时则直接赋予maxRowNum小于0则直接赋予0
startRowIndex = (startRowIndex > maxRowNum) ? maxRowNum : startRowIndex;
startRowIndex = (startRowIndex >= maxRowNum) ? maxRowNum - 1 : startRowIndex;
startRowIndex = startRowIndex < 0 ? 0 : startRowIndex;
endRowIndex = (endRowIndex > maxRowNum) ? maxRowNum : endRowIndex;
endRowIndex = (endRowIndex >= maxRowNum) ? maxRowNum - 1 : endRowIndex;
endRowIndex = endRowIndex < 0 ? 0 : endRowIndex;
//若两个传值相同则endXXXIndex+1
@ -199,7 +231,7 @@ public class ListFileRead {
int minColumnIndex = startColumnIndex < endColumnIndex ? startColumnIndex : endColumnIndex;
int maxColumnIndex = startColumnIndex < endColumnIndex ? endColumnIndex : startColumnIndex;
int minRowIndex = startRowIndex < endRowIndex ? startRowIndex : endRowIndex;
int maxRowIndex = startRowIndex < endRowIndex ? endRowIndex : endRowIndex;
int maxRowIndex = startRowIndex < endRowIndex ? endRowIndex : startRowIndex;
//获取数据
for (int columnIndex = minColumnIndex; columnIndex < maxColumnIndex; columnIndex++) {
ArrayList<String> columnTextList = new ArrayList<>();

View File

@ -3,6 +3,7 @@ package pres.auxiliary.work.n.testcase.file;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
@ -19,6 +20,7 @@ import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import pres.auxiliary.tool.readfile.ListFileRead;
import pres.auxiliary.work.n.testcase.templet.LabelNotFoundException;
/**
@ -32,7 +34,7 @@ import pres.auxiliary.work.n.testcase.templet.LabelNotFoundException;
* <b>编码时间</b>2020年2月11日下午11:12:56
* </p>
* <p>
* <b>修改时间</b>2020年2月11日下午11:12:56
* <b>修改时间</b>2020年4月1日下午7:11:18
* </p>
*
* @author 彭宇琦
@ -284,18 +286,7 @@ public class TestCaseTemplet {
titleCell.setCellStyle(columnStyle(xw));
// 添加数据获取相应datas下的所有data标签
List<Element> dataList = datasList.get(datasIndex).elements();
for (int j = 0; j < dataList.size(); j++) {
//判断当前行是否被创建若未被创建则创建其行并创建单元格反之则直接创建单元格
XSSFRow row;
// 添加数据若该行已被创建则直接获取来创建单元格
if ((row = dataSheet.getRow(++rowIndex)) == null) {
dataSheet.createRow(rowIndex).createCell(columnIndex)
.setCellValue(dataList.get(j).attributeValue("name"));
} else {
row.createCell(columnIndex).setCellValue(dataList.get(j).attributeValue("name"));
}
}
writeDataValidity(datasList.get(datasIndex), dataSheet, rowIndex, columnIndex);
}
}
}
@ -328,4 +319,69 @@ public class TestCaseTemplet {
return xcs;
}
/**
* 用于将写入数据有效性至相应的sheet页
* @param datasElement
* @param dataSheet
* @param rowIndex
* @param columnIndex
*/
@SuppressWarnings("unchecked")
private void writeDataValidity(Element datasElement, XSSFSheet dataSheet, int rowIndex, int columnIndex) {
// 添加数据获取相应datas下的所有data标签
List<Element> dataElementList = datasElement.elements();
ArrayList<String> dataTextList = new ArrayList<>();
for (int j = 0; j < dataElementList.size(); j++) {
//判断标签是否为文件标签若为文件标签则读取外部数据
if ("file".equalsIgnoreCase(dataElementList.get(j).getName())) {
try {
dataTextList.addAll(getFileDataValidity(dataElementList.get(j)));
} catch (Exception e) {
//若抛出任何异常则说明xml配置不正确故不进行操作
}
} else {
dataTextList.add(dataElementList.get(j).attributeValue("name"));
}
}
//写入文件
for (String dataText : dataTextList) {
//判断当前行是否被创建若未被创建则创建其行并创建单元格反之则直接创建单元格
XSSFRow row;
// 添加数据若该行已被创建则直接获取来创建单元格
if ((row = dataSheet.getRow(++rowIndex)) == null) {
dataSheet.createRow(rowIndex).createCell(columnIndex)
.setCellValue(dataText);
} else {
row.createCell(columnIndex).setCellValue(dataText);
}
}
}
/**
* 用于获取写在外部文件中的数据有效性
* @param textElement 数据标签
* @return 从外部文件中读取到的数据
*/
private ArrayList<String> getFileDataValidity(Element textElement) {
ArrayList<String> dataList = new ArrayList<>();
try {
//读取数据有效性文件内容
File dataFile = new File(textElement.attributeValue("path"));
String sheet = textElement.attributeValue("regex");
ListFileRead lfr = new ListFileRead(dataFile, sheet);
//存储需要读取的列和行信息
int columnIndex = Integer.valueOf(textElement.attributeValue("column"));
int startRowIndex = Integer.valueOf(textElement.attributeValue("start_row"));
int endRowIndex = Integer.valueOf(textElement.attributeValue("end_row"));
//获取数据信息
dataList.addAll(lfr.getColumn(columnIndex, startRowIndex, endRowIndex));
} catch (Exception e) {
//若抛出任何异常则说明xml配置不正确故不进行操作
}
return dataList;
}
}

View File

@ -32,6 +32,7 @@ import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import pres.auxiliary.tool.readfile.ListFileRead;
import pres.auxiliary.work.n.testcase.templet.Case;
import pres.auxiliary.work.n.testcase.templet.LabelNotFoundException;
@ -121,10 +122,7 @@ public class TestCaseWrite {
} catch (DocumentException e) {
throw new IncorrectFileException("用例xml文件有误");
}
// 获取xml文件中的第一个sheet标签则将该标签的name属性内容传入getColumnId中
switchSheet(configXml.getRootElement().element("sheet").attributeValue("name"));
// 判断路径是否包含.xlsx使用的方法为XSSFWork
if (caseFile.isFile() && caseFile.getAbsolutePath().indexOf(".xlsx") > -1) {
this.caseFile = caseFile;
@ -132,6 +130,9 @@ public class TestCaseWrite {
throw new IncorrectFileException("不正确的文件格式:" + caseFile.getAbsolutePath());
}
// 获取xml文件中的第一个sheet标签则将该标签的name属性内容传入getColumnId中
switchSheet(configXml.getRootElement().element("sheet").attributeValue("name"));
// 创建存储测试用例的document类对象
caseXml = DocumentHelper.createDocument();
// 写入根节点
@ -710,17 +711,22 @@ public class TestCaseWrite {
// 查找xml文件中数据有效性标签
List<Element> datasList = sheetElement.elements("datas");
ArrayList<String> datas = new ArrayList<String>();
// 遍历所有的数据有效性标签若存在将datas设置为true
// 遍历所有的数据有效性标签若存在存储相应的数据有效性
for (Element datasElemenet : datasList) {
if (datasElemenet.attributeValue("id").equals(column.get(index).attributeValue("id"))) {
//存储当前的数据有效性的内容
((List<Element>)(datasElemenet.elements())).forEach(textElement -> {
datas.add(textElement.attributeValue("name"));
//判断数据有效性的存放位置并按照相应的方法读取数据有效性
if ("file".equalsIgnoreCase(textElement.getName())) {
datas.addAll(getFileDataValidity(textElement));
} else {
datas.add(getLabelDataValidity(textElement));
}
});
break;
}
}
// 存储字段信息
fieldMap.put(column.get(index).attributeValue("id"),
new Field(column.get(index).attributeValue("id"), column.get(index).attributeValue("align"), index,
@ -729,6 +735,41 @@ public class TestCaseWrite {
}
}
/**
* 用于获取写在xml文件中的数据有效性
* @param textElement 数据标签
* @return 标签内的数据
*/
private String getLabelDataValidity(Element textElement) {
return textElement.attributeValue("name");
}
/**
* 用于获取写在外部文件中的数据有效性
* @param textElement 数据标签
* @return 从外部文件中读取到的数据
*/
private ArrayList<String> getFileDataValidity(Element textElement) {
ArrayList<String> dataList = new ArrayList<>();
try {
//读取数据有效性文件内容
File dataFile = new File(textElement.attributeValue("path"));
String sheet = textElement.attributeValue("regex");
ListFileRead lfr = new ListFileRead(dataFile, sheet);
//存储需要读取的列和行信息
int columnIndex = Integer.valueOf(textElement.attributeValue("column"));
int startRowIndex = Integer.valueOf(textElement.attributeValue("start_row"));
int endRowIndex = Integer.valueOf(textElement.attributeValue("end_row"));
//获取数据信息
dataList.addAll(lfr.getColumn(columnIndex, startRowIndex, endRowIndex));
} catch (Exception e) {
//若抛出任何异常则说明xml配置不正确故不进行操作
}
return dataList;
}
/**
* 用于对需要进行替换的特殊词语进行替换
* @param contents 文本内容
@ -1154,6 +1195,9 @@ public class TestCaseWrite {
/**
* 用于创建表格的数据有效性若当前字段无数据有效性或文件中无数据有效性 相应的内容时则不创建数据有效性
* @param caseSheet 用例所在sheet
* @param startRowIndex 起始行下标
* @param endRowIndex 结束行下标
*/
public void addDataValidation(XSSFSheet caseSheet, int startRowIndex, int endRowIndex) {
// 判断当前是否存在数据有效性不存在则结束

View File

@ -2,6 +2,7 @@ package pres.auxiliary.tool.readfile;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeTest;
@ -10,10 +11,10 @@ import org.testng.annotations.Test;
public class ListFileReadTest {
ListFileRead lfr;
// @BeforeTest
// public void start() throws IOException {
// lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.csv"));
// }
@BeforeTest
public void start() throws IOException {
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.txt"), "\\t");
}
@AfterMethod
public void showColumn() {
@ -27,7 +28,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Csv() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.csv"));
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.csv"));
lfr.getColumn(4).forEach(System.out :: println);
System.out.println("------------------------------------");
}
@ -38,7 +39,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Xls() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.xls"));
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.xls"));
lfr.getColumn(4).forEach(System.out :: println);
System.out.println("------------------------------------");
}
@ -49,7 +50,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Xls_String() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.xls"), "Sheet2");
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.xls"), "Sheet2");
}
/**
@ -58,7 +59,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Xlsx() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.xlsx"));
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.xlsx"));
lfr.getColumn(4).forEach(System.out :: println);
System.out.println("------------------------------------");
}
@ -69,7 +70,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Xlsx_String() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.xlsx"), "Sheet2");
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.xlsx"), "Sheet2");
}
/**
@ -78,7 +79,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Txt() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.txt"));
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.txt"));
}
/**
@ -87,7 +88,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Txt_String() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.txt"), "\\t");
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.txt"), "\\t");
}
/**
@ -96,7 +97,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Doc() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.doc"));
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.doc"));
}
/**
@ -105,7 +106,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_Doc_String() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.doc"), "\\t");
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.doc"), "\\t");
}
/**
@ -114,7 +115,7 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_docx() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.docx"));
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.docx"));
}
/**
@ -123,7 +124,66 @@ public class ListFileReadTest {
*/
@Test
public void listFileReadTest_docx_String() throws IOException {
lfr = new ListFileRead(new File("src/test/java/pres/auxiliary/tool/readfile/模块信息.docx"), "\\t");
lfr = new ListFileRead(new File("Test/ListDataFile/模块信息.docx"), "\\t");
}
/**
* 测试{@link ListFileRead#getColumn(int, int, int)}
*/
@Test
public void getColumnTest() {
lfr.getColumn(2, 3, 6).forEach(System.out :: println);
System.out.println("------------------------------------");
lfr.getColumn(2, 4, 0).forEach(System.out :: println);
System.out.println("------------------------------------");
lfr.getColumn(2, 3, 3).forEach(System.out :: println);
System.out.println("------------------------------------");
lfr.getColumn(99, 99, 99).forEach(System.out :: println);
System.out.println("------------------------------------");
}
/**
* 测试{@link ListFileRead#getTable()}
*/
@Test
public void getTableTest() {
AtomicInteger commitCount = new AtomicInteger(1);
lfr.getTable().forEach(textList -> {
System.out.println("" + commitCount.getAndIncrement() + "列:");
textList.forEach(System.out :: println);
});
System.out.println("------------------------------------");
}
/**
* 测试{@link ListFileRead#getTable(int, int, int, int)}
*/
@Test
public void getTableTest_IntIntIntInt() {
AtomicInteger commitCount = new AtomicInteger(1);
lfr.getTable(0, 2, 3, 6).forEach(textList -> {
System.out.println("" + commitCount.getAndIncrement() + "列:");
textList.forEach(System.out :: println);
});
System.out.println("------------------------------------");
commitCount.set(1);
lfr.getTable(2, 0, 4, 0).forEach(textList -> {
System.out.println("" + commitCount.getAndIncrement() + "列:");
textList.forEach(System.out :: println);
});
System.out.println("------------------------------------");
commitCount.set(1);
lfr.getTable(2, 2, 4, 4).forEach(textList -> {
System.out.println("" + commitCount.getAndIncrement() + "列:");
textList.forEach(System.out :: println);
});
System.out.println("------------------------------------");
commitCount.set(1);
lfr.getTable(99, 99, 99, 99).forEach(textList -> {
System.out.println("" + commitCount.getAndIncrement() + "列:");
textList.forEach(System.out :: println);
});
System.out.println("------------------------------------");
}
@Test

View File

@ -1,17 +0,0 @@
第1模块,呵呵,嘻嘻,第34模块,第50模块,
第2模块,第14模块,第24模块,第35模块,第51模块,第63模块
第3模块,第15模块,第25模块,第36模块,第52模块,第64模块
第4模块,第16模块,第26模块,第37模块,第53模块,第65模块
第5模块,第17模块,第27模块,第38模块,第54模块,第66模块
第6模块,第18模块,第28模块,第39模块,第55模块,第67模块
第7模块,第19模块,第29模块,第40模块,第56模块,第68模块
第8模块,第20模块,第30模块,第41模块,第57模块,第69模块
第9模块,第21模块,第31模块,第42模块,第58模块,第70模块
第10模块,第22模块,第32模块,第43模块,第59模块,第71模块
第11模块,第23模块,第33模块,第44模块,,第72模块
第12模块,,哈哈,第45模块,,第73模块
第13模块,,,第46模块,,第74模块
,,,第47模块,,第75模块
,,,第48模块,第60模块,第76模块
,,,第49模块,第61模块,第77模块
,,,咯咯,第62模块,
1 第1模块 呵呵 嘻嘻 第34模块 第50模块
2 第2模块 第14模块 第24模块 第35模块 第51模块 第63模块
3 第3模块 第15模块 第25模块 第36模块 第52模块 第64模块
4 第4模块 第16模块 第26模块 第37模块 第53模块 第65模块
5 第5模块 第17模块 第27模块 第38模块 第54模块 第66模块
6 第6模块 第18模块 第28模块 第39模块 第55模块 第67模块
7 第7模块 第19模块 第29模块 第40模块 第56模块 第68模块
8 第8模块 第20模块 第30模块 第41模块 第57模块 第69模块
9 第9模块 第21模块 第31模块 第42模块 第58模块 第70模块
10 第10模块 第22模块 第32模块 第43模块 第59模块 第71模块
11 第11模块 第23模块 第33模块 第44模块 第72模块
12 第12模块 哈哈 第45模块 第73模块
13 第13模块 第46模块 第74模块
14 第47模块 第75模块
15 第48模块 第60模块 第76模块
16 第49模块 第61模块 第77模块
17 咯咯 第62模块

View File

@ -1,5 +0,0 @@
第1.0模块 第2.0模块
第1.1模块 第2.1模块
第1.2模块 第2.2模块
第1.3模块 第2.3模块
第1.4模块 第2.4模块

View File

@ -24,6 +24,10 @@
<data name='Normal' />
<data name='Low' />
</datas>
<datas id='模块'>
<file path='Test/ListDataFile/模块信息.xlsx' regex='Sheet1' column='2' start_row='2' end_row='11' />
</datas>
</sheet>
<!-- 测试程序时使用 -->

Binary file not shown.