140 likes | 236 Vues
Learn how to prompt for confirmation on exit to prevent losing unsaved changes in your application. Code example and tips included.
E N D
Test Driving Your S-Wing By Patrick Kua emailpat <at> thekua.com || pkua <at> thoughtworks.com
Unit Integration Tests x 10 Unit Tests x 100s 0010110101010110101000101101010110101000101101010101101010001012101010101101010010110101010111001010001011000010 Code Developer Loop Acceptance Tests x1
Confirm Exit As an author I would like to be prompted for confirmation on exit so that I do not lose any unsaved changes
VS Source Test
public void testOnExitIAmAskedForConfirmation() { MainApplication application = TestHelper.getMainApplication(); ConfirmationDialog dialog = application.clickExit(); assertNotNull(dialog); assertEquals(“Are you sure you want to Exit?”, dialog.getMessage()); dialog.clickCancel(); assertTrue(application.isShowing()); }
How To Implement • No Frameworks (yay!) • Model View Presenter • Test Things Only Worth Testing • Unit Test as Much as Possible • Code Changes Based on Tests • Demonstration…
Glue Layout Managers Presenters Views Repository How it all works (Yawn… I mean Architecture)
Implementing Confirmation of Exit Actually Exit
Abbot & Costello Alternatives include: • Marathon Man • http://marathonman.sourceforge.net • Jemmy (Netbeans) • http://jacareto.sourceforge.net • Jacreto • http://jacareto.sourceforge.net • JFC Unit • http://jfcunit.sourceforge.net • Pounder • http://pounder.sourceforge.net http://abbot.sourceforge.net/
The resources for this presentation can be found at: http://www.thekua.com/conferences/xp2006 Questions?