0
我的屬性文件看起來是這樣的:Programmaticaly分配屬性值到@參數
demo6312623.mockable.io/testingmoke = 200;aaaa
www.google.com = 200;bbbb
我需要遍歷在文件中的所有屬性和傳遞的參數是這樣的:
Object[][] data = new Object[][] {
{ 200, "demo6312623.mockable.io/testing", "aaaa"},
{ 200, "www.google.com", "bbbb"}
}
我可以迭代通過屬性文件是這樣的:
for (Map.Entry<Object, Object> props : props.entrySet()) {
System.out.println((String)props.getKey() +" nnnnn "+ (String)props.getValue());
}
但我不知道如何通過這些參數TER值這個方法:
@Parameters
public static Collection <Object[]> addedNumbers() throws IOException {
props = new Properties();
FileInputStream fin = new FileInputStream("src/test/resources/application.properties");
props.load(fin);
for (Map.Entry < Object, Object > props: props.entrySet()) {
System.out.println((String) props.getKey() + " nnnnn " + (String) props.getValue());
}
// not sure how to assign the values to the 2 dimensional array by splitting from ";"
// Object[][] data = new Object[][]{
// { 200, "demo6312623.mockable.io/testing", "aaaa"},
// { 200, "www.google.com", "bbbb"}
// };
return Arrays.asList(data);
}