content.txt
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
RowFixture also supports functions, so you can check on the objects that you query. For example, lets say that we have a database of employee objects. We want to test that the employees were paid correctly.
|!-fitnesse.fixtures.EmployeePayRecordsRowFixture-!|
|id|pay()|
|1|1000|
|2|2000|
As you can see, we query the employees by ''id'', and then check to see that their pay was correct. Here's what it would look like if their pay was not correct.
|!-fitnesse.fixtures.EmployeePayRecordsRowFixture-!|
|id|pay()|
|1|1000|
|2|3000|
And here is what it would look like if there were missing or extra employees
|!-fitnesse.fixtures.EmployeePayRecordsRowFixture-!|
|id|pay()|
|1|1000|
|5|5000|
Here is the code for the fixtures:{{{package fitnesse.fixtures;
import fit.RowFixture;
public class EmployeePayRecordsRowFixture extends RowFixture {
public Object[] query() throws Exception {
EmployeePayRecord[] records = new EmployeePayRecord[2];
records[0] = new EmployeePayRecord(1, 1000);
records[1] = new EmployeePayRecord(2,2000);
return records;
}
public Class getTargetClass() {
return EmployeePayRecord.class;
}
} }}}----{{{package fitnesse.fixtures;
public class EmployeePayRecord {
public int id;
private double salary;
public EmployeePayRecord(int id, double salary) {
this.id = id;
this.salary = salary;
}
public double pay() {
return salary;
}
} }}}
!img http://files/images/runArrow.gif For more about RowFixture see RowFixtureMultipleKeys