SlideShare une entreprise Scribd logo
1  sur  27
SWTBot: Unit Testing Made Easy Eclipse Day India 2011 Ankit Goel 6th May, 2011
Agenda PART I – About SWTBot Introduction to SWTBot SWTBot Features Supported Widgets Test Executions PART II - Integrating SWTBot tests execution with continuous build system What more? Limitations
PART I – About SWTBot
Introduction – What is SWTBot? Java based UI/functional testing tool for testing SWT and Eclipse based applications Set of API’s to access and manipulate widgets Cross platform Free and open source Still in Incubation Phase in Eclipse
Introduction – Why SWTBot? Why not QTP? Why not PDE Junit? Why not… Provides an intuitive way to access and test UI components in Eclipse UI Testing covers all layers of software Easy to learn if someone is already familiar with Java and JUnit Can integrate very well within the IDE and provides excellent support for integration with Ant
Introduction – Who is it for? Developers Unit tests Integration with build ensures quality builds QA Test automation Quality product
Setting up Eclipse environment SWTBot update site http://www.eclipse.org/swtbot/downloads.php Create a plugin project and setup dependencies org.eclipse.ui org.eclipse.core.runtime org.eclipse.swtbot.eclipse.finder org.eclipse.swtbot.junit4_x org.eclipse.swtbot.swt.finder org.junit4 org.hamcrest Or, create a SWTBot test plugin
How does it work? SWTBot = bot which acts on SWT components Entry point: org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot Helper classes for widgets To test: Instantiate bot SWTWorkbenchBotbot = new SWTWorkbenchBot(); Click on button SWTBotButton button = bot.button("Hello, World!“); button.click(); Congrats! You have just written your first SWTBOT test 
SWTBot Features Finding controls based on visual cues Support for simulated mouse and keyboard input Querying widgets for state UI specific assertions like: assertEnabled(Widget) Investigating test failures
SWTBot Features – Finding Controls Controls can be found based on visual cues like: Text Label Group Tooltip Ids Combination of all or any of the above (Using matchers) Eg: Find textbox that has a label 'Username:‘ SWTBotText username = bot.textWithLabel("Username:");  Identify button using tooltip  SWTBotToolbarButton save = bot.toolbarButtonWithTooltip("Save");
SWTBot Features – Using matchers Simple matchers withText(“Finish”) withLabel(“Username:”) withRegex(“Proceed to step * ”) widgetOfType(Button.class) withStyle(SWT.ARROW, “SWT.ARROW”) Combination of matchers allOf(matchers) anyOf(matchers) not(matchers)
Filtering controls using Matchers Match : widgets of type 'Label'  	with regular expression 'Welcome, <USERNAME>'  Matcher matcher = allOf(  widgetOfType(Label.class),  withRegex("Welcome, .*") );  Get the label that matches the matcher  SWTBotLabel label =  	new SWTBotLabel((Label) bot.widget(matcher));
SWTBot Features – Simulate input   SWTBot provides API to simulate actions on widgets Eg: Click a button button.click();  Select a item in combobox comboBox.select(“Option 12");  Type in a textbox text.typeText(“This is a demo string");  Expand tree tree.expandNode("MyProject", "src", "com", "example", "MyClass.java");
SWTBot Features – Querying widgets Provides operations to query the state of widgets Some generic queries like: getText(), isEnabled(), isVisible() are available on all widgets Eg: Check state of a checkbox booleanchecked = checkbox.isChecked(); Check if a radio button is selected boolean selected = radio.isSelected();
SWTBot Features – Investigating test failures Stack trace in Junit view Capturing screen shot when test case fails @RunWith(SWTBotJunit4ClassRunner.class) publicclassMessageCreateTest{ ...  … }
Supported Widgets Support for most SWT controls Support for most UI operations on SWT controls Support for Eclipse based contributions: Views Text Editors (autocompletion, typing, etc) View Toolbars and View Menus
SWT Test Execution By launching them from launch configuration (same as Junit execution) From command line, using shell script or ant
Demo A small SWTBot example illustrating the simplicity of SWTBot Your first SWTBot
PART II – Integrating SWTBot tests execution with continuous build system
Integration of test execution with continuous build Build plugins to be tested Build SWTBot test plugins Install plugins to be tested, test plugins and headless testing framework (http://www.eclipse.org/swtbot/downloads.php) into eclipse Start SWTBot test case execution Format the generated report and mail if required
Pre-requisite Each test plugin must contain test.xml Set appropriate properties Delegate execution of test to a library file Test plugins should always be ‘unpacked’
Under the covers… For each test plugin Invoke test.xml which will Set required properties like class name, plugin name, directory to use as temp workspace etc Invoke target ‘swtbot-test’ of library file located in ‘org.eclipse.swtbot.eclipse.junit4.headless’ plugin which will then launch and execute all test cases Invoke target ‘collect’ of library file located in ‘org.eclipse.swtbot.eclipse.junit4.headless’ plugin which will consolidate test case results in one file Format the generated results file (xml file) into desired format (usually html)
Snippet – test.xml <anttarget="swtbot-test"antfile="${library-file}"dir="${eclipse-home}"> 	<property name="data-dir"value="${temp-workspace}" /> 	<propertyname="plugin-name"value="${plugin-name}" /> 	<propertyname="classname”value=“${class-name}" /> 	<propertyname="vmargs"value=" -Xms128M -Xmx368M -	XX:MaxPermSize=256M" /> </ant>
Still confused ? This would surely help
What more? Parse results file and fail build if any of the test fails – ensuring only quality builds go to QA Code Coverage – write more tests to test uncovered code
Limitations Less documentation available Some SWT widgets not supported yet! No support for other UI toolkits – GEF, Nebula etc
SwtBot: Unit Testing Made Easy

Contenu connexe

Tendances

Declarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeDeclarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeRamon Ribeiro Rabello
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMashleypuls
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introductionJonathan Holloway
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with MockitoRichard Paul
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Ajinkya Saswade
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootJosué Neis
 
Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jestpksjce
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in javaAdil Mehmoood
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Nelson Glauber Leal
 

Tendances (20)

Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Declarative UIs with Jetpack Compose
Declarative UIs with Jetpack ComposeDeclarative UIs with Jetpack Compose
Declarative UIs with Jetpack Compose
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASM
 
Spring boot - an introduction
Spring boot - an introductionSpring boot - an introduction
Spring boot - an introduction
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
UIAutomator
UIAutomatorUIAutomator
UIAutomator
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Selenium TestNG
Selenium TestNGSelenium TestNG
Selenium TestNG
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
 
Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI Android jetpack compose | Declarative UI
Android jetpack compose | Declarative UI
 
Java Applet
Java AppletJava Applet
Java Applet
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Katalon Studio - GUI Overview
Katalon Studio - GUI OverviewKatalon Studio - GUI Overview
Katalon Studio - GUI Overview
 
Introduction to java 8 stream api
Introduction to java 8 stream apiIntroduction to java 8 stream api
Introduction to java 8 stream api
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jest
 
Swing and AWT in java
Swing and AWT in javaSwing and AWT in java
Swing and AWT in java
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021
 

En vedette

Functional Testing made easy with SWTBot for Developers and Testers
Functional Testing made easy with SWTBot for Developers and TestersFunctional Testing made easy with SWTBot for Developers and Testers
Functional Testing made easy with SWTBot for Developers and TestersAurélien Pupier
 
проблеми на основање на ново претпријатие 2
проблеми на основање на ново претпријатие  2проблеми на основање на ново претпријатие  2
проблеми на основање на ново претпријатие 2samo_ti
 
Avani Realtors and Developers
Avani Realtors and DevelopersAvani Realtors and Developers
Avani Realtors and DevelopersAtul Vaja
 
S first year orientation history of university of san carlos 1 - copy
S first year orientation history of university of san carlos 1 - copyS first year orientation history of university of san carlos 1 - copy
S first year orientation history of university of san carlos 1 - copySis Mmfe Navarro
 
Правописание приставок. ЕГЭ задание 9
Правописание приставок. ЕГЭ задание 9Правописание приставок. ЕГЭ задание 9
Правописание приставок. ЕГЭ задание 9Elena Erastova
 
Lista silvai bellini sindaco
Lista silvai bellini sindacoLista silvai bellini sindaco
Lista silvai bellini sindacoMartina Garberi
 
Countable,uncountable
Countable,uncountableCountable,uncountable
Countable,uncountableÒrsida Sevo
 
Sustentabilidade no visual merchandising de moda
Sustentabilidade no visual merchandising de modaSustentabilidade no visual merchandising de moda
Sustentabilidade no visual merchandising de modaMMdaMODA
 
E recruitment kit (eng)
E recruitment kit (eng)E recruitment kit (eng)
E recruitment kit (eng)maatbk
 
TALLER DE ORIENTACIÓN VOCACIONAL
TALLER DE ORIENTACIÓN VOCACIONALTALLER DE ORIENTACIÓN VOCACIONAL
TALLER DE ORIENTACIÓN VOCACIONALM Dolores Camps
 

En vedette (16)

Functional Testing made easy with SWTBot for Developers and Testers
Functional Testing made easy with SWTBot for Developers and TestersFunctional Testing made easy with SWTBot for Developers and Testers
Functional Testing made easy with SWTBot for Developers and Testers
 
Soial culture
Soial cultureSoial culture
Soial culture
 
Healthy Homes
Healthy HomesHealthy Homes
Healthy Homes
 
p
pp
p
 
Bni edsonluciano-apr
Bni edsonluciano-aprBni edsonluciano-apr
Bni edsonluciano-apr
 
проблеми на основање на ново претпријатие 2
проблеми на основање на ново претпријатие  2проблеми на основање на ново претпријатие  2
проблеми на основање на ново претпријатие 2
 
Avaliação de história di
Avaliação de história diAvaliação de história di
Avaliação de história di
 
Avani Realtors and Developers
Avani Realtors and DevelopersAvani Realtors and Developers
Avani Realtors and Developers
 
S first year orientation history of university of san carlos 1 - copy
S first year orientation history of university of san carlos 1 - copyS first year orientation history of university of san carlos 1 - copy
S first year orientation history of university of san carlos 1 - copy
 
Enigma & radar
Enigma & radarEnigma & radar
Enigma & radar
 
Правописание приставок. ЕГЭ задание 9
Правописание приставок. ЕГЭ задание 9Правописание приставок. ЕГЭ задание 9
Правописание приставок. ЕГЭ задание 9
 
Lista silvai bellini sindaco
Lista silvai bellini sindacoLista silvai bellini sindaco
Lista silvai bellini sindaco
 
Countable,uncountable
Countable,uncountableCountable,uncountable
Countable,uncountable
 
Sustentabilidade no visual merchandising de moda
Sustentabilidade no visual merchandising de modaSustentabilidade no visual merchandising de moda
Sustentabilidade no visual merchandising de moda
 
E recruitment kit (eng)
E recruitment kit (eng)E recruitment kit (eng)
E recruitment kit (eng)
 
TALLER DE ORIENTACIÓN VOCACIONAL
TALLER DE ORIENTACIÓN VOCACIONALTALLER DE ORIENTACIÓN VOCACIONAL
TALLER DE ORIENTACIÓN VOCACIONAL
 

Similaire à SwtBot: Unit Testing Made Easy

Testing Java Web Apps With Selenium
Testing Java Web Apps With SeleniumTesting Java Web Apps With Selenium
Testing Java Web Apps With SeleniumMarakana Inc.
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 
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
 
SoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSmartBear
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 
Coded ui - lesson 1 - overview
Coded ui - lesson 1 - overviewCoded ui - lesson 1 - overview
Coded ui - lesson 1 - overviewOmer Karpas
 
12 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 200912 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 2009Pepe
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
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
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testingalessiopace
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.comtestingbot
 
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)Tech OneStop
 

Similaire à SwtBot: Unit Testing Made Easy (20)

Swtbot
SwtbotSwtbot
Swtbot
 
Testing Java Web Apps With Selenium
Testing Java Web Apps With SeleniumTesting Java Web Apps With Selenium
Testing Java Web Apps With Selenium
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
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
 
SoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPluginsSoapUI Pro Plugin Workshop #SoapUIPlugins
SoapUI Pro Plugin Workshop #SoapUIPlugins
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
10071756.ppt
10071756.ppt10071756.ppt
10071756.ppt
 
JsUnit
JsUnitJsUnit
JsUnit
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
Coded ui - lesson 1 - overview
Coded ui - lesson 1 - overviewCoded ui - lesson 1 - overview
Coded ui - lesson 1 - overview
 
12 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 200912 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 2009
 
Jsunit
JsunitJsunit
Jsunit
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
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
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Selenium Testing with TestingBot.com
Selenium Testing with TestingBot.comSelenium Testing with TestingBot.com
Selenium Testing with TestingBot.com
 
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
 

Dernier

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
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...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

SwtBot: Unit Testing Made Easy

  • 1. SWTBot: Unit Testing Made Easy Eclipse Day India 2011 Ankit Goel 6th May, 2011
  • 2. Agenda PART I – About SWTBot Introduction to SWTBot SWTBot Features Supported Widgets Test Executions PART II - Integrating SWTBot tests execution with continuous build system What more? Limitations
  • 3. PART I – About SWTBot
  • 4. Introduction – What is SWTBot? Java based UI/functional testing tool for testing SWT and Eclipse based applications Set of API’s to access and manipulate widgets Cross platform Free and open source Still in Incubation Phase in Eclipse
  • 5. Introduction – Why SWTBot? Why not QTP? Why not PDE Junit? Why not… Provides an intuitive way to access and test UI components in Eclipse UI Testing covers all layers of software Easy to learn if someone is already familiar with Java and JUnit Can integrate very well within the IDE and provides excellent support for integration with Ant
  • 6. Introduction – Who is it for? Developers Unit tests Integration with build ensures quality builds QA Test automation Quality product
  • 7. Setting up Eclipse environment SWTBot update site http://www.eclipse.org/swtbot/downloads.php Create a plugin project and setup dependencies org.eclipse.ui org.eclipse.core.runtime org.eclipse.swtbot.eclipse.finder org.eclipse.swtbot.junit4_x org.eclipse.swtbot.swt.finder org.junit4 org.hamcrest Or, create a SWTBot test plugin
  • 8. How does it work? SWTBot = bot which acts on SWT components Entry point: org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot Helper classes for widgets To test: Instantiate bot SWTWorkbenchBotbot = new SWTWorkbenchBot(); Click on button SWTBotButton button = bot.button("Hello, World!“); button.click(); Congrats! You have just written your first SWTBOT test 
  • 9. SWTBot Features Finding controls based on visual cues Support for simulated mouse and keyboard input Querying widgets for state UI specific assertions like: assertEnabled(Widget) Investigating test failures
  • 10. SWTBot Features – Finding Controls Controls can be found based on visual cues like: Text Label Group Tooltip Ids Combination of all or any of the above (Using matchers) Eg: Find textbox that has a label 'Username:‘ SWTBotText username = bot.textWithLabel("Username:"); Identify button using tooltip SWTBotToolbarButton save = bot.toolbarButtonWithTooltip("Save");
  • 11. SWTBot Features – Using matchers Simple matchers withText(“Finish”) withLabel(“Username:”) withRegex(“Proceed to step * ”) widgetOfType(Button.class) withStyle(SWT.ARROW, “SWT.ARROW”) Combination of matchers allOf(matchers) anyOf(matchers) not(matchers)
  • 12. Filtering controls using Matchers Match : widgets of type 'Label' with regular expression 'Welcome, <USERNAME>' Matcher matcher = allOf( widgetOfType(Label.class), withRegex("Welcome, .*") ); Get the label that matches the matcher SWTBotLabel label = new SWTBotLabel((Label) bot.widget(matcher));
  • 13. SWTBot Features – Simulate input SWTBot provides API to simulate actions on widgets Eg: Click a button button.click(); Select a item in combobox comboBox.select(“Option 12"); Type in a textbox text.typeText(“This is a demo string"); Expand tree tree.expandNode("MyProject", "src", "com", "example", "MyClass.java");
  • 14. SWTBot Features – Querying widgets Provides operations to query the state of widgets Some generic queries like: getText(), isEnabled(), isVisible() are available on all widgets Eg: Check state of a checkbox booleanchecked = checkbox.isChecked(); Check if a radio button is selected boolean selected = radio.isSelected();
  • 15. SWTBot Features – Investigating test failures Stack trace in Junit view Capturing screen shot when test case fails @RunWith(SWTBotJunit4ClassRunner.class) publicclassMessageCreateTest{ ... … }
  • 16. Supported Widgets Support for most SWT controls Support for most UI operations on SWT controls Support for Eclipse based contributions: Views Text Editors (autocompletion, typing, etc) View Toolbars and View Menus
  • 17. SWT Test Execution By launching them from launch configuration (same as Junit execution) From command line, using shell script or ant
  • 18. Demo A small SWTBot example illustrating the simplicity of SWTBot Your first SWTBot
  • 19. PART II – Integrating SWTBot tests execution with continuous build system
  • 20. Integration of test execution with continuous build Build plugins to be tested Build SWTBot test plugins Install plugins to be tested, test plugins and headless testing framework (http://www.eclipse.org/swtbot/downloads.php) into eclipse Start SWTBot test case execution Format the generated report and mail if required
  • 21. Pre-requisite Each test plugin must contain test.xml Set appropriate properties Delegate execution of test to a library file Test plugins should always be ‘unpacked’
  • 22. Under the covers… For each test plugin Invoke test.xml which will Set required properties like class name, plugin name, directory to use as temp workspace etc Invoke target ‘swtbot-test’ of library file located in ‘org.eclipse.swtbot.eclipse.junit4.headless’ plugin which will then launch and execute all test cases Invoke target ‘collect’ of library file located in ‘org.eclipse.swtbot.eclipse.junit4.headless’ plugin which will consolidate test case results in one file Format the generated results file (xml file) into desired format (usually html)
  • 23. Snippet – test.xml <anttarget="swtbot-test"antfile="${library-file}"dir="${eclipse-home}"> <property name="data-dir"value="${temp-workspace}" /> <propertyname="plugin-name"value="${plugin-name}" /> <propertyname="classname”value=“${class-name}" /> <propertyname="vmargs"value=" -Xms128M -Xmx368M - XX:MaxPermSize=256M" /> </ant>
  • 24. Still confused ? This would surely help
  • 25. What more? Parse results file and fail build if any of the test fails – ensuring only quality builds go to QA Code Coverage – write more tests to test uncovered code
  • 26. Limitations Less documentation available Some SWT widgets not supported yet! No support for other UI toolkits – GEF, Nebula etc

Notes de l'éditeur

  1. QTP:Pre-work required – repositoryNot cross platform – runs only on windows – no linux supportEven though its one of the fastest tools in the market – its still slower than SWTBotLearning requiredBetter because multiple types of apps can be supportedSWTBot provides APIs that are simple to read and write.No-hassle tool for writing powerful tests
  2. SWTBot provides APIs that are simple to read and write. These APIs hide away the complexities of SWT and Eclipse. This makes it suitable for use by everyone and not just developers.
  3. If you scroll down the stack trace in the JUnit view, you’ll see the cause of the error.The@RunWith(SWTBotJunit4ClassRunner.class)annotation captures a screenshot in a screenshots directory in your project. Refresh your project to see the new folder.
  4. List of Not Yet Supported SWT WidgetsButton Arrow,Browser,Canvas,Composite,CTabFolder,Link,ProgressBar,Sash,Scale, ScrolledComposite,Slider,Spinner,TabFolderNot Yet Supported UI ToolkitsGEFEclipse FormsNebulaeSWT &amp; eRCPRAP (work in progress)Native Dialogs (MessageBox, FileDialog, ColorDialog etc.)Most of it is planned to be supported them ASAP
  5. A demo mapping all the theory learnt so far into a practical example
  6. It&apos;s generally accepted that writing tests as part of software development is a very good thing indeed. It&apos;s also generally accepted that automating the running of tests in an automated or nightly build is good engineering practice. Let&apos;s face it, if tests are not run automatically then there&apos;s a good chance they won&apos;t be run at all, and tests that are not run are next to useless.SWTBot provides an excellent framework to write and run unit tests for your plug-ins that can be run from within the Eclipse environment.Once you have taken the time and effort to write these valuable unit tests, how do you automate the running of these unit tests so that you can integrate them into your automated build?
  7. A demo showing how execution on unit tests can be integrated with the regular build system
  8. List of Not Yet Supported SWT WidgetsButton Arrow,Browser,Canvas,Composite,CTabFolder,Link,ProgressBar,Sash,Scale, ScrolledComposite,Slider,Spinner,TabFolderNot Yet Supported UI ToolkitsGEFEclipse FormsNebulaeSWT &amp; eRCPRAP (work in progress)Native Dialogs (MessageBox, FileDialog, ColorDialog etc.)Most of it is planned to be supported them ASAP