package examples; import static org.junit.Assert.*; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import org.junit.Test; public class SomeViewTest { @Test public void testViewUpdating() { SomeModelState model = new SomeModelState(); SomeView view = new SomeView(model); JFrame f = new JFrame(); f.add(view); f.pack(); f.setVisible(true); // some manual checks: userCheck("See spot?"); model.setName(model.getName() + " run"); userCheck("See spot run?"); //an automatic test: assertEquals(model.getName(), ((JButton) view).getText()); } void userCheck(String s) { if (JOptionPane.showConfirmDialog(null, s) == JOptionPane.NO_OPTION) fail(); } }