-
Notifications
You must be signed in to change notification settings - Fork 2
TableParameters
jochenwierum edited this page Jul 9, 2012
·
1 revision
Fit has build-in support for table parameters. Table parameters are parameters, which are passed right after the fixture class name. FitGoodies parses them and provides functions to easy access them.
MyFixture | BeFast = 1 | EnableSpecialTests = 0 |
---|---|---|
x | y | result() |
1 | 1 | 5 |
2 | 4 | 3 |
import de.cologneintelligence.fitgoodies.ColumnFixture;
import de.cologneintelligence.fitgoodies.util.FixtureTools;
public class MyFixture extends ColumnFixture {
public int x;
public int y;
private boolean beFast;
private boolean specialTests;
@Override
public void setUp() throws Exception {
super.setUp();
beFast = getBoolParameter("BeFast", "true");
specialTests = getBoolParameter("EnableSpecialTests", "false");
}
private boolean getBoolParameter(String name, String defaultValue) {
String param = getParam(name, defaultValue);
return FixtureTools.convertToBoolean(param);
}
public int result() {
Result resultGenerator = new ResultGenerator(x, y);
resultGenerator.setDoSpecialTests(specialTests);
resultGenerator.setFastProcessing(beFast);
return resultGenerator.getResultingInt();
}
}
A shorter way is to create variables with the same name and declaring them as public; do whatever you like more:
public class MyFixture extends ColumnFixture {
public int x;
public int y;
public boolean BeFast;
public boolean EnableSpecialTests;
public int result() {
Result resultGenerator = new ResultGenerator(x, y);
resultGenerator.setDoSpecialTests(specialTests);
resultGenerator.setFastProcessing(beFast);
return resultGenerator.getResultingInt();
}
}