I was thinking of sending the expected data into a constructor but then realized it was a silly idea.
I still would rather minimize typing.
I have an extensive xml config file. Some elements inside of it may appear multiple times (ei, multiple channel
tags). For those elements my plan was to make a 'tester' that can be called to validate each individual channel & their respective values. I'm at a loss of how to do this with JUnit.
The plan is to have 2 config files with opposing configurations.
Parameterized was the answer. Thanks.
Here's an example I whipped up if anyone wants further examples:
@RunWith(Parameterized.class)
public class GlobalTester{
@Parameter(0)
public Configuration config;
@Parameter(1)
public boolean debug;
@Parameters
public static Collection<Object[]> params() throws Exception{
List<Object[]> inputs = new LinkedList<Object[]>();
Object[] o = new Object[2];
o[0] = ConfigurationSuite.load(1);
o[1] = true;
inputs.add(o);
o = new Object[2];
o[0] = ConfigurationSuite.load(2);
o[1] = false;
inputs.add(o);
return inputs;
}
@Test
public void debug(){
assertEquals(debug, config.getGeneral().isDebug());
}
}