SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
Enabling Test-First Development for
            Eclipse UI


                 Matthias Kempka
       Innoopract Informationssysteme GmbH
Outline

 Problem description
 Components for testing UI programmatically
 Test Case with JFace/Workbench Robot Sammy
Creating code test-driven

   TDD creates little pieces of code
   Readable
   Simple
   Flexible
   Regression tests already there
   Great, uh?



                               Unit Tests


                                   Piece of Code
Where should I put it?

 A framework has many hooks
 Did I hook up my PoC in the right spot?
 Did I hook it up at all?




                            Eclipse Framework




                               Piece of Code
„Testing“ by hand

 Easiest approach: Try it.
 Regression tests?

                              *click*


                   Developer
                                                    use


                                Eclipse Framework




                                    Piece of Code
PDE Tests

 Let's write regression tests
 PDE tests can start our test code with a workbench
 Some Eclipse functionality is hard to reach programmatically


                PDE Unit Tests


                             Eclipse Framework




                                 Piece of Code
Functional Tests with SWT Robots

 SWT Robots can simulate User interaction
 Is it easier to find a ViewAction button on the screen than in the Workbench
  API?

        PDE Unit Tests
                         use   SWT       *click*
                               Robot

                                                       use

                                 Eclipse Framework




                                       Piece of Code
Are SWT Robots the solution?

 Can find SWT widgets in the widget hierarchy
 Provides convenience methods to use the widgets
 Can read feedback from the UI


                                                  Display


                                                    Shell


                                                 Composite


                                         Label               Text
What's not in the Widget Hierarchy?

 Basically all objects an Eclipse programmer touches are not in the widget
  hierarchy
 Association with IDs from plugin.xml is lost



              Display                  IViewPart            IActionDelegate

               Shell                      IMarker
                                                      IEditorPart

             Composite                 TreeViewer
                                                              IHandler

     Label               Text                TableViewer
                                                                    ...
Functional Tests with Robots

 A JFace/Workbench Robot eases access to the interesting parts of the UI.
 Provides access to JFace controllers

                            SWT Robot *click*
       PDE Unit Tests
                          JFace/Workbench
                          Robot
                                                       use


                                 Eclipse Framework




                                   Piece of Code
Sammy: The Mission



    Make common things easy, make difficult things possible


 I need to set up test data for the TableViewer behind this SWT Table on the
  screen? How can I reach it?
 I'm writing a view. How can I test that all the listeners are attached correctly?
 I'm writing a contribution to a view (i.e. a ViewAction) – How can I test that
  my entries in plugin.xml works?
 Does my LabelProvider return the right image?
Writing a test with JFace/Workbench Robot
Sammy

Write a test case:
 Set up: Prepare a view for the actual test
    – open the view
 Tear down:
  – Clean up allocated resources: Close the view
 Actual test
    –   Find the TableViewer in that view and set a test-specific input
    –   Check that a view action is not enabled
    –   Select an item in the table
    –   Check that the view action is enabled
Set up: Open a view

 Views could be opened using IWorkbenchPage.showView( id )
    – Too cumbersome for such a common use case
    – No immediate feedback on errors




   Sammy.openView( id ) eases setting up test cases
    – easy accessible API
    – Show errors in red test case instead of UI
    – Remembers the view for cleaning up

public void setup() throws Exception {
  sammy = new Sammy();
  sammy.openView( ViewUnderTest.ID );
}
Tear down

 Instances of Sammy (and SammyIDE) remember the resources they
  allocated and can release (close or delete) them
   – IViewPart
   – IEditorPart
   – IResource




public void teardown() throws Exception {
  sammy.cleanup();
}
Test: Finding the view

 Every supported JFace/Workbench Element has an Operator:
   –   IViewPart – ViewOperator
   –   IEditorPart – EditorOperator
   –   TableViewer – TableViewerOperator
   –   …
 The Operator gives access to the described JFace/Workbench element
   – Convenience methods for common use cases
 Operator constructor
   – takes parameters that describe the JFace/Workbench element
   – returns without Exception only if the described element was found
   – waits a time for the element to appear



public void testViewAction() throws Exception {
  ViewOperator vo = new ViewOperator( “View Title” );
}
Test: Finding the TableViewer

 Operators for workbench parts know their parent composite
   – Given in IWorkbenchPart.createPartControl( Composite )
 Operators for JFace elements
   – take a parent of the SWT element or the SWT element itself
   – can associate the SWT element with the JFace abstraction



public void testViewAction() throws Exception {
  ViewOperator vo = new ViewOperator( “View Title” );
  TableViewerOperator tvo = new TableViewerOperator(
                                vo.getParentComposite() );
}
Test: Setting the Input

 Setting up Test Data often includes setting a special input on a viewer
 Having the TableViewer already available eases this remarkably
 *Operator.getSource()returns the actual JFace/Workbench element




public void testViewAction() throws Exception {
  ViewOperator vo = new ViewOperator( “View Title” );
  TableViewerOperator tvo = new TableViewerOperator(
                                vo.getParentComposite() );
  tvo.getSource().setInput( new String[] { “a” } );
}
Test: Checking ViewerOperator enablement

 A ViewActionDelegate only is instanciated once the user selects the
  ViewAction
 The ViewActionOperator knows the Proxy by the workbench as well as
  the delegate




public void testViewAction() throws Exception {
  ViewOperator vo = new ViewOperator( “View Title” );
  TableViewerOperator tvo = new TableViewerOperator(
                                vo.getParentComposite() );
  tvo.getSource().setInput( new String[] { “a” } );
  ViewActionOperator vao = new ViewActionOperator( vo,
                               MyViewAction.ID );
  assertFalse( vao.isEnabled() );
}
Test: Checking ViewerOperator enablement

 Now all the elements are in place to make this test useful
    – The View shows up (layout is not tested)
    – XML Code in plugin.xml is tested
    – Makes sure that the TableViewer is a SelectionProvider




public void testViewAction() throws Exception {
  ViewOperator vo = new ViewOperator( “View Title” );
  TableViewerOperator tvo = new TableViewerOperator(
                                vo.getParentComposite() );
  tvo.getSource().setInput( new String[] { “a” } );
  ViewActionOperator vao = new ViewActionOperator( vo,
                               MyViewAction.ID );
  assertFalse( vao.isEnabled() );
  tvo.getSource().setSelection( new StructuredSelection(“a”));
  assertTrue( vao.isEnabled() );
}
Sammy Internals

 For many things, Sammy relies on mapping from widgets to
  JFace/Workbench elements
   – And vice versa
 Some widgets are nowhere accessible in the workbench
   – Where necessary aspects are used to trap widget instances
 For some things, Sammy has to access internals
   – i.e. the View that shows an error holds it in a private field
   – This leads to compatibility layers, but at least it's in one place




            Widget                                          Viewer
Sammy Future

 More than proof of concept, less than beta
 A good state to start collecting requirements
 http://www.innoopract.com/en/developers/mkempka/sammy
The End



http://www.innoopract.com/en/developers/mkempka/sammy

Weitere ähnliche Inhalte

Was ist angesagt?

Selenium notes
Selenium notesSelenium notes
Selenium noteswholcomb
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android ApplicationsRody Middelkoop
 
Codeception presentation
Codeception presentationCodeception presentation
Codeception presentationAndrei Burian
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSJim Lynch
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for AndroidHazem Saleh
 
Scala for Test Automation
Scala for Test AutomationScala for Test Automation
Scala for Test Automationrthanavarapu
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Codescidept
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...7mind
 
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingAgile Testing Alliance
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Lars Vogel
 
Scala, Functional Programming and Team Productivity
Scala, Functional Programming and Team ProductivityScala, Functional Programming and Team Productivity
Scala, Functional Programming and Team Productivity7mind
 
JavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and EcosystemJavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and EcosystemAlexander Casall
 

Was ist angesagt? (17)

Codeception
CodeceptionCodeception
Codeception
 
Selenium notes
Selenium notesSelenium notes
Selenium notes
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Codeception presentation
Codeception presentationCodeception presentation
Codeception presentation
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
 
React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
 
Scala for Test Automation
Scala for Test AutomationScala for Test Automation
Scala for Test Automation
 
UI Testing
UI TestingUI Testing
UI Testing
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
 
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
 
Selenium Handbook
Selenium HandbookSelenium Handbook
Selenium Handbook
 
Scala, Functional Programming and Team Productivity
Scala, Functional Programming and Team ProductivityScala, Functional Programming and Team Productivity
Scala, Functional Programming and Team Productivity
 
JavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and EcosystemJavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and Ecosystem
 
Selenium
SeleniumSelenium
Selenium
 

Andere mochten auch

Presentacion
PresentacionPresentacion
Presentaciondiver4a
 
43 old photos rares-i
43 old photos rares-i43 old photos rares-i
43 old photos rares-ifilipj2000
 
The FLIP Side of Telling Your Story: the Neighborhood Centers Inc Experience
The FLIP Side of Telling Your Story: the Neighborhood Centers Inc ExperienceThe FLIP Side of Telling Your Story: the Neighborhood Centers Inc Experience
The FLIP Side of Telling Your Story: the Neighborhood Centers Inc ExperienceIABC Houston
 
Marketing 500 new TLDs on a Shoestring
Marketing 500 new TLDs on a ShoestringMarketing 500 new TLDs on a Shoestring
Marketing 500 new TLDs on a ShoestringBlacknight
 
575 madame tussaud wien-iii
575 madame tussaud wien-iii575 madame tussaud wien-iii
575 madame tussaud wien-iiifilipj2000
 

Andere mochten auch (8)

Presentacion
PresentacionPresentacion
Presentacion
 
43 old photos rares-i
43 old photos rares-i43 old photos rares-i
43 old photos rares-i
 
The FLIP Side of Telling Your Story: the Neighborhood Centers Inc Experience
The FLIP Side of Telling Your Story: the Neighborhood Centers Inc ExperienceThe FLIP Side of Telling Your Story: the Neighborhood Centers Inc Experience
The FLIP Side of Telling Your Story: the Neighborhood Centers Inc Experience
 
Retoquedigital
RetoquedigitalRetoquedigital
Retoquedigital
 
Flower Lover Catalogue 2012
Flower Lover Catalogue 2012Flower Lover Catalogue 2012
Flower Lover Catalogue 2012
 
Marketing 500 new TLDs on a Shoestring
Marketing 500 new TLDs on a ShoestringMarketing 500 new TLDs on a Shoestring
Marketing 500 new TLDs on a Shoestring
 
575 madame tussaud wien-iii
575 madame tussaud wien-iii575 madame tussaud wien-iii
575 madame tussaud wien-iii
 
Switzerland1
Switzerland1Switzerland1
Switzerland1
 

Ähnlich wie 081107 Sammy Eclipse Summit2

Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Mikkel Flindt Heisterberg
 
Dependency Injection in .NET applications
Dependency Injection in .NET applicationsDependency Injection in .NET applications
Dependency Injection in .NET applicationsBabak Naffas
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnetVlad Maniak
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
 
TestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorialTestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorialLee Seungjong
 
Oscon2007 Windmill
Oscon2007 WindmillOscon2007 Windmill
Oscon2007 Windmilloscon2007
 
Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5John.Jian.Fang
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to proDomenico Gemoli
 
Tellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.TestingTellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.TestingJohn.Jian.Fang
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXAlex Ruiz
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXAlex Ruiz
 
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCUI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCJim Lane
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Fwdays
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsDror Bereznitsky
 

Ähnlich wie 081107 Sammy Eclipse Summit2 (20)

Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
Dependency Injection in .NET applications
Dependency Injection in .NET applicationsDependency Injection in .NET applications
Dependency Injection in .NET applications
 
Selenium withnet
Selenium withnetSelenium withnet
Selenium withnet
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
TestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorialTestersChoice_plug-in_tutorial
TestersChoice_plug-in_tutorial
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
 
Oscon2007 Windmill
Oscon2007 WindmillOscon2007 Windmill
Oscon2007 Windmill
 
Test
TestTest
Test
 
Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5Tellurium.A.New.Approach.For.Web.Testing.V5
Tellurium.A.New.Approach.For.Web.Testing.V5
 
End to-end testing from rookie to pro
End to-end testing  from rookie to proEnd to-end testing  from rookie to pro
End to-end testing from rookie to pro
 
Tellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.TestingTellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.Testing
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFX
 
Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFX
 
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCUI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
 
Jsf tutorial
Jsf tutorialJsf tutorial
Jsf tutorial
 
Coding Naked
Coding NakedCoding Naked
Coding Naked
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance Diagnostics
 

Kürzlich hochgeladen

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

Kürzlich hochgeladen (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

081107 Sammy Eclipse Summit2

  • 1. Enabling Test-First Development for Eclipse UI Matthias Kempka Innoopract Informationssysteme GmbH
  • 2. Outline  Problem description  Components for testing UI programmatically  Test Case with JFace/Workbench Robot Sammy
  • 3. Creating code test-driven  TDD creates little pieces of code  Readable  Simple  Flexible  Regression tests already there  Great, uh? Unit Tests Piece of Code
  • 4. Where should I put it?  A framework has many hooks  Did I hook up my PoC in the right spot?  Did I hook it up at all? Eclipse Framework Piece of Code
  • 5. „Testing“ by hand  Easiest approach: Try it.  Regression tests? *click* Developer use Eclipse Framework Piece of Code
  • 6. PDE Tests  Let's write regression tests  PDE tests can start our test code with a workbench  Some Eclipse functionality is hard to reach programmatically PDE Unit Tests Eclipse Framework Piece of Code
  • 7. Functional Tests with SWT Robots  SWT Robots can simulate User interaction  Is it easier to find a ViewAction button on the screen than in the Workbench API? PDE Unit Tests use SWT *click* Robot use Eclipse Framework Piece of Code
  • 8. Are SWT Robots the solution?  Can find SWT widgets in the widget hierarchy  Provides convenience methods to use the widgets  Can read feedback from the UI Display Shell Composite Label Text
  • 9. What's not in the Widget Hierarchy?  Basically all objects an Eclipse programmer touches are not in the widget hierarchy  Association with IDs from plugin.xml is lost Display IViewPart IActionDelegate Shell IMarker IEditorPart Composite TreeViewer IHandler Label Text TableViewer ...
  • 10. Functional Tests with Robots  A JFace/Workbench Robot eases access to the interesting parts of the UI.  Provides access to JFace controllers SWT Robot *click* PDE Unit Tests JFace/Workbench Robot use Eclipse Framework Piece of Code
  • 11. Sammy: The Mission Make common things easy, make difficult things possible  I need to set up test data for the TableViewer behind this SWT Table on the screen? How can I reach it?  I'm writing a view. How can I test that all the listeners are attached correctly?  I'm writing a contribution to a view (i.e. a ViewAction) – How can I test that my entries in plugin.xml works?  Does my LabelProvider return the right image?
  • 12. Writing a test with JFace/Workbench Robot Sammy Write a test case:  Set up: Prepare a view for the actual test – open the view  Tear down: – Clean up allocated resources: Close the view  Actual test – Find the TableViewer in that view and set a test-specific input – Check that a view action is not enabled – Select an item in the table – Check that the view action is enabled
  • 13. Set up: Open a view  Views could be opened using IWorkbenchPage.showView( id ) – Too cumbersome for such a common use case – No immediate feedback on errors  Sammy.openView( id ) eases setting up test cases – easy accessible API – Show errors in red test case instead of UI – Remembers the view for cleaning up public void setup() throws Exception { sammy = new Sammy(); sammy.openView( ViewUnderTest.ID ); }
  • 14. Tear down  Instances of Sammy (and SammyIDE) remember the resources they allocated and can release (close or delete) them – IViewPart – IEditorPart – IResource public void teardown() throws Exception { sammy.cleanup(); }
  • 15. Test: Finding the view  Every supported JFace/Workbench Element has an Operator: – IViewPart – ViewOperator – IEditorPart – EditorOperator – TableViewer – TableViewerOperator – …  The Operator gives access to the described JFace/Workbench element – Convenience methods for common use cases  Operator constructor – takes parameters that describe the JFace/Workbench element – returns without Exception only if the described element was found – waits a time for the element to appear public void testViewAction() throws Exception { ViewOperator vo = new ViewOperator( “View Title” ); }
  • 16. Test: Finding the TableViewer  Operators for workbench parts know their parent composite – Given in IWorkbenchPart.createPartControl( Composite )  Operators for JFace elements – take a parent of the SWT element or the SWT element itself – can associate the SWT element with the JFace abstraction public void testViewAction() throws Exception { ViewOperator vo = new ViewOperator( “View Title” ); TableViewerOperator tvo = new TableViewerOperator( vo.getParentComposite() ); }
  • 17. Test: Setting the Input  Setting up Test Data often includes setting a special input on a viewer  Having the TableViewer already available eases this remarkably  *Operator.getSource()returns the actual JFace/Workbench element public void testViewAction() throws Exception { ViewOperator vo = new ViewOperator( “View Title” ); TableViewerOperator tvo = new TableViewerOperator( vo.getParentComposite() ); tvo.getSource().setInput( new String[] { “a” } ); }
  • 18. Test: Checking ViewerOperator enablement  A ViewActionDelegate only is instanciated once the user selects the ViewAction  The ViewActionOperator knows the Proxy by the workbench as well as the delegate public void testViewAction() throws Exception { ViewOperator vo = new ViewOperator( “View Title” ); TableViewerOperator tvo = new TableViewerOperator( vo.getParentComposite() ); tvo.getSource().setInput( new String[] { “a” } ); ViewActionOperator vao = new ViewActionOperator( vo, MyViewAction.ID ); assertFalse( vao.isEnabled() ); }
  • 19. Test: Checking ViewerOperator enablement  Now all the elements are in place to make this test useful – The View shows up (layout is not tested) – XML Code in plugin.xml is tested – Makes sure that the TableViewer is a SelectionProvider public void testViewAction() throws Exception { ViewOperator vo = new ViewOperator( “View Title” ); TableViewerOperator tvo = new TableViewerOperator( vo.getParentComposite() ); tvo.getSource().setInput( new String[] { “a” } ); ViewActionOperator vao = new ViewActionOperator( vo, MyViewAction.ID ); assertFalse( vao.isEnabled() ); tvo.getSource().setSelection( new StructuredSelection(“a”)); assertTrue( vao.isEnabled() ); }
  • 20. Sammy Internals  For many things, Sammy relies on mapping from widgets to JFace/Workbench elements – And vice versa  Some widgets are nowhere accessible in the workbench – Where necessary aspects are used to trap widget instances  For some things, Sammy has to access internals – i.e. the View that shows an error holds it in a private field – This leads to compatibility layers, but at least it's in one place Widget Viewer
  • 21. Sammy Future  More than proof of concept, less than beta  A good state to start collecting requirements  http://www.innoopract.com/en/developers/mkempka/sammy