我是Apache poi的新手。我有一个具有许多断言检查的测试,也使用apache poi插件来获取测试参数。现在,如果测试中的任何断言都失败,我会尝试将其写入另一个具有相同测试参数但具有测试结果的Excel工作表中。下面是我的代码-
@RunWith(Parameterized.class)
public class testClass {
ExcelUtils ex = new ExcelUtils(path);
@Parameters
public static String[][] data() {
String[][] tableArray = ex.getTableArray("sheet1");
return (tableArray);
}
private final String TN;
private final String Pro;
public testClass(String TN, String Pro) {
this.TN = TN;
this.Pro = Pro;
}
@Test
public void test() {
System.out.Println(TN);
System.out.println(Pro);
//Also Code which has lots of assert operations
}
@Rule
public TestRule listen = new TestWatcher() {
@Override
protected void failed(Throwable e, Description description) {
//I need help to write code to capturetest result
}
};
}
我正在使用junit测试框架