October 2000
Intermediate to advanced
288 pages
5h 45m
English
We'll build tests for the 0, 1, and many cases:
public void test0() {
SearchPanel sp = new SearchPanel();
sp.setSearcher (new TestSearcher());
sp.queryField.setText("0");
sp.findButton.doClick();
assert("Empty result", sp.resultTable.getRowCount() == 0);
}
At last, we're using the GUI: setting text fields, clicking buttons, and so on.
We run the test, and it passes! This means we already have a working solution if our searcher always returns zero items.
We move on:
public void test1() { SearchPanel sp = new SearchPanel(); sp.setSearcher (new TestSearcher()); sp.queryField.setText("1"); sp.findButton.doClick(); assert("1-row result", sp.resultTable.getRowCount() == 1); assertEquals( "a0", sp.resultTable.getValueAt(0,0).toString()); ...Read now
Unlock full access