java - 如何在 selenium 中使用 Excel 和 junit 进行参数化(读取隐藏的 excel 数据)
问题描述
嗨,我正在尝试从外部文件中获取数据,并在运行时读取并加载到测试脚本(多个测试用例)中,而不是对其进行硬编码或使用 @parameter 注释,我不想提及我的参数或我的数据如下所示的脚本,
@RunWith(Parameterized.class)
public class Class_Test {
@Parameter(0)
public String name;
@Parameter(1)
public String type;
@Parameter(2)
public String username;
@Parameter(3)
public String password;
@Parameter(4)
public String email;
@Parameters(name = "{1}")
public static String[][] data() throws IOException {
return Reader.readDataFromExcel("Core_Test");
}
}
有什么办法可以隐藏我的变量而不是在测试脚本中公开它们
解决方案
参数由带有@Parameters 注释的方法生成。您可以使用此方法从 Excel 电子表格中读取数据。
@Parameters
public static Object[][] data() {
//read the date here from the Excel file.
}
推荐阅读
- mongodb - Play Reactive Mongo Plugin for Play 2.4 和 ReactiveMongo 0.13
- python - 如何使用 Notify 和 python 只清除一条通知消息?
- anylogic - Anylogic Fluids:管理批次
- python - IndexError:索引 9 超出轴 0 的范围,大小为 9 // python 3
- jquery - 隐藏视频标签中的放大控制 - Edge 和 IE
- botframework - 通过 Microsoft.PowerBI.Api.V2 使用 BotFramework 访问 PowerBi
- ruby - 如何整理Ruby、Passenger和Rack的多个版本(Apache下)
- android - 在 android studio 中创建库时出错
- regex - 正则表达式捕获字符串
- javascript - Grunt 生成新的 node_modules