TestN and More

Write testN(), with, say, five items. It will also pass.

What else can give you problems? One possible problem occurs when we do a sequence of queries—can we get "leftovers"? For example, a query returning five items followed by a query returning three items should have only three items in the table. (If the table were improperly cleared, we might see the last two items of the previous query.)

We can test a sequence of queries:

 public void testQuerySequenceForLeftovers() { SearchPanel sp = new SearchPanel(); sp.setSearcher (new TestSearcher()); sp.queryField.setText("5"); sp.findButton.doClick(); assert(sp.resultTable.getRowCount() == 5); sp.queryField.setText("3"); sp.findButton.doClick(); assert(sp.resultTable.getRowCount() ...

Get Extreme Programming Installed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.