Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Red-Green-Refactor! EclipseCon 2008 Kevin P. Taylor, Nicolaus Malnick Test-Driven Development (TDD) for Eclipse RCP."— 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)

17 ©2008 Obtiva Corporation Model-View-Presenter (MVP)

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

19 ©2008 Obtiva Corporation Databinding API as MVP Courtesy of http://wiki.eclipse.org/JFace_Data_Binding_Introductionhttp://wiki.eclipse.org/JFace_Data_Binding_Introduction

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

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/http://www.eclipse.org/tptp/ Fitster - http://sourceforge.net/project/showfiles.php?group_id=134927 http://sourceforge.net/project/showfiles.php?group_id=134927 Rational Tester - http://www- 306.ibm.com/software/awdtools/tester/f unctional/http://www- 306.ibm.com/software/awdtools/tester/f unctional/

30 ©2008 Obtiva Corporation References Continued SWTBot - http://swtbot.sourceforge.net/wiki/Main_Page 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.


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

Similar presentations


Ads by Google