Suppose you have a panel with a table, which I will call a pane.
The table has a toolbar above it, including an edit button.
Editing involves showing an editing dialog. It allows the user to edit the record associated with the table's selected row and submit it which disposes the dialog and refreshes the table. The dialog is basically a form.
I write a GUI test for the pane.
Should I somehow mock the dialog? If so, how?
Should the pane accept some
Supplier? Say,Supplier<MyEditingDialog>orSupplier<MyEditableEntity>(the latter would return the record after editing).How should the pane accept whatever it should accept via a constructor or setter? There's no way it should accept some constructor parameter for each of its toolbar's buttons (it would bloat the parameter list). On the other hand, I can't say those toolbar functionalities (create, edit, delete) are optional, so I'm not sure about involving setters either. Builder? I don't feel good about it either.
As of now, the edit() method hardcodedly creates and shows a specific dialog (new MyEditingDialog()). If I keep it as is, then my test would in effect test two things: the pane and the dialog. I am not sure you can call any GUI test a "unit" test really, but I would prefer to keep its scope tighter, focusing on testing the pane's functionality.
Java 8.