Reputation: 1705
Trying to model some data for a parameterized junit test but am having trouble understanding how to make it actually work. The data I am trying to work with is of the form:
{
{
"A String",
{
{ "xxx", "yyy", "zzz" },
{ "aaa", "bbb", "ccc" }
},
},
{
"Another String",
{
{ "abc", "def", "ghi" },
{ "qwe", "asd", "zxc" },
{ "rty", "fgh", "vbn" }
}
}
}
I know how to organize it, but not how to express it in usable java terms that I can pass to parameterized tests.
UPDATE:
I did eventually puzzle it out:
@Parameters( name = "Test ({index}" )
public static Collection< Object[] > data()
{
return Arrays.asList( new Object[][]
{
{
"A String",
new Object[]
{
new String[]{ "xxx", "yyy", "zzz" },
new String[]{ "aaa", "bbb", "ccc" }
},
},
{
"Another String",
new Object[]
{
new String[]{ "abc", "def", "ghi" },
new String[]{ "qwe", "asd", "zxc" },
new String[]{ "rty", "fgh", "vbn" }
}
}
} );
}
Upvotes: 0
Views: 91
Reputation: 18792
I am not entirely sure what you need. Wold this be appropriate ?
Map<String, String[][]> map = new HashMap<>();
map.put("A String",new String[][] {{"xxx", "yyy", "zzz"},{"aaa","bbb","ccc"}});
Upvotes: 1