Testing Key Widgets

We proposed a screen design earlier. The first thing we can test is that key widgets are present: a label, a query field, a button, and a table. There may be other components on the panel (for example, subpanels used for organization), but we don't care about them.

So we'll create testWidgetsPresent().To make this work, we need a.panel for the overall screen ("SearchPanel"), the label ("searchLabel"), a textfield for entering the query ("queryField"), a button ("findButton"), and a table for the results ("resultTable"). We'll let these widgets be package-access, so our test can see them.

 public void testWidgetsPresent() { SearchPanel panel = new SearchPanel(); assertNotNull(panel.searchLabel); assertNotNull(panel.queryField); ...

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.