[英]Passing String array as a parameter to JUnit test
I'm using @Parameter for Field injection while writing a JUNIT test. 我在编写JUNIT测试时使用@Parameter进行字段注入。 Is it possible to pass a String array to the data object[][]. 是否可以将String数组传递给数据对象[] []。 I mean in the below code can I pass a string array like this 我的意思是在下面的代码中我可以传递这样的字符串数组
{"Input1","Input2", {"file1","file2"}}
Code Snippet 代码段
@RunWith(Parameterized.class)
public class AModuleTest {
@Parameters
public static Iterable<Object[]> testData() {
Object[][] data = new Object[][]{
{"Input1","Input2", }
};
return Arrays.asList(data);
}
@Parameter(value=0) public String tabName;
@Parameter(value=1) public String fileSetName;
@Parameter(value=2) public String[] fileNames
@Test
public void ATest(){
//here I'm just passing those parameters to these functions clickTab, Navigate()...
clickTab(tabName);
Navigate(fileSet);
}
}
So I figured that we can create an array within arrays; 所以我想我们可以在数组中创建一个数组。 by creating a String array within the data Object like 通过在数据对象内创建一个String数组,例如
Object[][] data = new Object[][]{
{"Input1","Input2", new String[] {"file1", "file2"} }
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.