1 / 29

Test-Driven Development TDD for Eclipse RCP

chidi
Download Presentation

Test-Driven Development TDD for Eclipse RCP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Red-Green-Refactor! EclipseCon 2008 Kevin P. Taylor, Nicolaus Malnick Test-Driven Development (TDD) for Eclipse RCP

    2. ©2008 Obtiva Corporation Kevin P. Taylor President, Obtiva Former editor: java.about.com Author: Test-Driven Development in Java course Presenter: EclipseCon, EclipseWorld, Agile Conference and other events Former technical lead on large Eclipse RCP project

    3. ©2008 Obtiva Corporation Nicolaus Malnick Senior Consultant, Obtiva Currently participating in a large Eclipse RCP project Test-driven development and pair programming advocate

    4. ©2008 Obtiva Corporation How are We Doing? Who uses JUnit consistently? For Eclipse RCP applications? Who writes their tests first? Who writes their tests after? Who finds time?

    5. ©2008 Obtiva Corporation Overview The Benefits of Test-Driven Development The Challenges of Test Driving Eclipse RCP The Heartbeat of Test-Driven Development Exercise: A Simple Example Tools of the Test-Driven Trade

    6. ©2008 Obtiva Corporation Overview Continued Exercise: Eclipse RCP TDD Example Functional Testing GUI Recorder Testing Conclusion References

    7. ©2008 Obtiva Corporation The Benefits of Doing TDD Cleaner code Only code what you need Tests interact with an malleable API Coding Confidence Increase code reliability Ensure rapid feedback DRY Code (Don’t Repeat Yourself) Constantly remove duplication Ruthless refactoring

    8. ©2008 Obtiva Corporation More Benefits of TDD Document our knowledge Technique for learning new libraries, frameworks and API’s Ensure we are writing tests at all!

    9. ©2008 Obtiva Corporation TDD Hurdles with Eclipse RCP Separation of concerns OSGi wires bundles at runtime SWT Widgets are difficult to mock

    10. ©2008 Obtiva Corporation The Heartbeat of TDD Red - Write a test that fails Green - Make it pass Refactor - Remove duplication Repeat

    11. ©2008 Obtiva Corporation Exercise: A Simple Example Fire up Eclipse and follow along!

    12. ©2008 Obtiva Corporation Tools of the Trade JUnit and JMock PDE JUnit Model-View-Presenter (MVP) pattern Presenter First Methodology

    13. ©2008 Obtiva Corporation JUnit and JMock Use for classes that are not dependent on Eclipse Platform API Particularly useful for testing business logic in model classes

    14. ©2008 Obtiva Corporation PDE JUnit (Plug-in JUnit) PDE JUnit tests are executed by a special test runner that launches another Eclipse instance in a separate VM. This means your tests can call the Eclipse Platform API, along with methods from your own plug-in.

    15. ©2008 Obtiva Corporation Enable Testing by Creating Layers MVC MVP Presenter First

    16. ©2008 Obtiva Corporation Model-View-Controller (MVC) Input --> Processing --> Output Controller --> Model --> View Con: Too difficult to have a thin/dumb view! View knows too much about model--forcing difficult testing of ViewInput --> Processing --> Output Controller --> Model --> View Con: Too difficult to have a thin/dumb view! View knows too much about model--forcing difficult testing of View

    17. ©2008 Obtiva Corporation Model-View-Presenter (MVP) Pattern for separating business logic from UI Isolates view and model via events 1 Presenter to Many Models 1 View to 1 Presenter Many Presenters to Many PresentersPattern for separating business logic from UI Isolates view and model via events 1 Presenter to Many Models 1 View to 1 Presenter Many Presenters to Many Presenters

    18. ©2008 Obtiva Corporation MVP Helps Us Separate concerns Minimize untested GUI code

    19. ©2008 Obtiva Corporation Databinding API as MVP

    20. ©2008 Obtiva Corporation Easier Eclipse RCP with Presenter First Drive unit tests against Presenter View and Model are interfaces Mock Implementation Actual Implementation Implement only the behavior required by each story Keep view dumb and minimal

    21. ©2008 Obtiva Corporation Exercise: TDD Mail Client Flip to Eclipse IDE!

    22. ©2008 Obtiva Corporation Functional Testing Unit Tests are not a silver bullet Functional tests exercise: presenter<->model<->DB How we can do it: Fitster/Fit An alternative to Presenter First Should set up data in DB using DBUnit Still doesn’t test the View but goes against the presenter or controllerAn alternative to Presenter First Should set up data in DB using DBUnit Still doesn’t test the View but goes against the presenter or controller

    23. ©2008 Obtiva Corporation Fitster/Fit Pre-alpha Run Fit tests from within Eclipse RCP applications

    24. ©2008 Obtiva Corporation GUI Recorder Testing Eclipse Test & Performance Tools Platform (TPTP) IBM Rational Tester SWTBot

    25. ©2008 Obtiva Corporation Test & Performance Tools Platform (TPTP) Automated GUI recorder API recorder Manual testing

    26. ©2008 Obtiva Corporation IBM Rational Tester Automated, functional testing and regression tool

    27. ©2008 Obtiva Corporation SWTBot Functional testing tool for SWT applications Should also work for Eclipse RCP Written by Ketan Padegaonkar, who is presenting on it at EclipseCon 2008

    28. ©2008 Obtiva Corporation Conclusion The Benefits of TDD The challenges we face test driving Eclipse RCP applications Tools of the trade Functional testing GUI testing

    29. ©2008 Obtiva Corporation References TPTP - http://www.eclipse.org/tptp/ Fitster - http://sourceforge.net/project/showfiles.php?group_id=134927 Rational Tester - http://www-306.ibm.com/software/awdtools/tester/functional/

    30. ©2008 Obtiva Corporation References Continued SWTBot - http://swtbot.sourceforge.net/wiki/Main_Page Gamma, E. & Beck, K., (2003), Contributing to Eclipse: Principles, Patterns, and Plug-Ins, Addison-Wesley. Alles, M., et al., (2006), “Presenter First: Organizing Complex GUI Applications for Test-Driven Development,” Agile 2006.

More Related