CombinationFixture is a specialised fixture for showing how pairs of values are expected to be combined. For example, here's a times table:
The fixture for this is as follows:
The method combine() is called for each pair of values, and the result checked. For example, for the cell in the last row above containing an expected value of 6, the method is called with the arguments combine(3,2).
In general, as usual:
The fixture for this class is as follows:
It just happens to refer to an object that is also a fixture.
fitlibrary.specify.TimesCombination | |||
1 | 2 | 3 | |
1 | 1 | 2 | 3 |
2 | 2 | 4 | 6 |
3 | 3 | 6 | 9 |
The fixture for this is as follows:
public class TimesCombination extends CombinationFixture {
public int combine(int x, int y) {
return x * y;
}
}
The method combine() is called for each pair of values, and the result checked. For example, for the cell in the last row above containing an expected value of 6, the method is called with the arguments combine(3,2).
In general, as usual:
- The given and expected values can be of any types
- A SystemUnderTest object (of any type) can be supplied to the CombinationFixture , so that the method combine() in that object is called instead. See the next example.
fitlibrary.specify.DirectCombination | |||
1 | 2 | 3 | |
100 | 100 | 200 | 300 |
220 | 220 | 440 | 660 |
330 | 330 | 660 | 990 |
The fixture for this class is as follows:
public class DirectCombination extends CombinationFixture {
public DirectCombination() {
super(new TimesCombination());
}
}
It just happens to refer to an object that is also a fixture.
- Copyright (c) 2004, 2005 Rick Mugridge, Rimu Research.
- Released under the terms of the GNU General Public License version 2 or later.
Add Child Page to CombinationFixture