应在Excel中的每一行执行测试用例

时间:2017-06-07 12:43:56

标签: java robotframework

我有一个场景,我必须从Excel工作表中提供测试数据,并且对于工作表中的每一行,测试用例应该再次执行。我怎么能这样做?

我已经编写了从excel表格中获取值的代码

create table TRIGGER_TEST
(
    col1 varchar2(64),
    col2 varchar2(64),
    col3 varchar2(64)
);

create or replace trigger TR_TRIGGER_TEST_1 
before update of COL1 on TRIGGER_TEST
for each row
begin
    dbms_output.put_line('here we are in TR_TRIGGER_TEST_1');
    :new.col2 := 'only testing';
end;
/

create or replace trigger TR_TRIGGER_TEST_2
before update of COL2 on TRIGGER_TEST
for each row
begin
    dbms_output.put_line('here we are in TR_TRIGGER_TEST_2');
    :new.col3 := 'trigger_test_2 has fired';
end;
/


insert into TRIGGER_TEST values ('1_col1','1_col2','1_col3');
select * from TRIGGER_TEST;

COL1                 COL2              COL3                                                    
----------------------------------------------------------------
1_col1               1_col2            1_col3                                                          

2 个答案:

答案 0 :(得分:1)

例如,来自“忙碌的开发者指南HSSF和XSSF功能”

  

https://poi.apache.org/spreadsheet/quick-guide.html#CellContents

Workbook wb = WorkbookFactory.create(new File("xlFileAddress.xlsOrXslx"));

for (Sheet sheet : wb ) {
    for (Row row : sheet) {
        for (Cell cell : row) {
            if(cell.getCellTypeEnum().equals(CellType.STRING)) {
                executeTestCase(cell.getRichStringCellValue().getString());
                // Do something else here
            }
        }
    }
}

答案 1 :(得分:0)

您可以使用Apache POI库来解析excel并在结果上创建测试。

https://poi.apache.org/