AcceptanceTestsWithFitNesse.
GuiTestWithOtherFixtures
Test Results
Assertions: 8 right, 0 wrong, 0 ignored, 0 exceptions
< GUI Test | Testing Datasets >

This is only the HTML version of the original WiKi-based tutorial.
You should download it from here to experience the real thing.

 Settings

Alternatives to ActionFixture

So with ActionFixture we directly test the UI by simulating user interactions. This workflow oriented do-this-then-do-that approach is quite nice, but the resulting table is anything but intuitive. Our first attempt with the ColumnFixture was much more descriptive.

Is this the only way to perform UI tests with FIT? Nope. Can do it with any Fixture. For example with our well known ColumnFixture. Let's have a look at our UI again:



Now we write a table that represents the data on the UI as simple as possible:

de.fitsample.timerecording.ui.TimeRecordingUIColumnFixture
day from to working time? sum?
1 6:30 12:00   5.5   5.5
  1 13:30 16:15 8.25 8.25
2 06:30 16:15 9 17.25
3 10:00 12:00   2.0   19.25
  3 12:45 17:00 6.25 23.5
4 8:00 12:00   4.0   27.5
  4 13:00 18:30 9.5 33.0

And here we go, click the Test button...

...cool, the same user interactions we saw with our ActionFixture, but the table is much more compact. So how the heck does this work now? This is done in our new Fixture:
public class TimeRecordingUIColumnFixture extends ColumnFixture {

public String day;
public String from;
public String to;

private TimeRecordingUI timeRecordingUI;

public TimeRecordingUIColumnFixture() {
timeRecordingUI = new TimeRecordingUI();
timeRecordingUI.pack();
timeRecordingUI.setVisible(true);
timeRecordingUI.toFront();
}

public void execute() {
sleep();
timeRecordingUI.dayTextField.setText(day);
sleep();
timeRecordingUI.fromTextField.setText(from);
sleep();
timeRecordingUI.toTextField.setText(to);
sleep();
timeRecordingUI.addButton.doClick();
sleep();
}

public double workingTime() {
TableModel model = timeRecordingUI.timeRecordTable.getModel();
Object value = model.getValueAt(model.getRowCount() - 1,
TimeRecordingTableModel.WORKING_TIME_COLUMN);
return ((Double) value).doubleValue();
}

public double sum() {
TableModel model = timeRecordingUI.timeRecordTable.getModel();
Object value = model.getValueAt(model.getRowCount() - 1,
TimeRecordingTableModel.SUM_COLUMN);
return ((Double) value).doubleValue();
}

protected void sleep() {
int slowMotionMs = 200;
try {
Thread.sleep(slowMotionMs);
} catch (InterruptedException excep) {
excep.printStackTrace();
}
}
}


Hmm, not that complicated. The ColumnFixture assigns values to the members day, from and to, and execute() performs the UI interactions. workingTime() and sum() are pretty much the same as in our ActionFixture.

Alright, but what about that sleep() method? This is that slow motion thing again, which we already had in our ActionFixture.

< GUI Test | Testing Datasets >


[.FrontPage] [.RecentChanges]