SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
UI Testing with Spec
The future is here… hace rato!
Pablo Tesone
Pharo Consortium Engineer
If it has no tests…
it does not exist.
Dr. Test (1987 - …)
A little strong… but…
Missing Tests
Fear of Changes
Unknown Impact
Bad Surprises
Pain… lots of pain…
Really…
If I delete something or break it…
How long it will take to detect the
error?
We all love tests.
That is easy
We need to test the UI
Testing UI is difficult
We need special tools
Selenium,
Watir,
Cypress,
or Cucumber
with just Objects & Polymorphism
Es al pedo!
j'ai la flemme!
2 similar but different
problems.
• Testing Spec implementation itself (Adapters,
Presenters, Widgets, Layouts, Backends, etc)

• Testing Applications written in Spec (display,
interactions, update, navigations)
Before
Refactoring… we
need tests!
Testing Spec
• Spec has a nice modular implementation, different
objects with different responsibilities
Presenters AdaptersLayouts Widgets
• Spec is a big monster, maybe not so big… but
scary… maybe not so scary:
Testing Spec
Presenters
• Interaction with the Model

• Events

• Public API

• Default Values
Adapters
Lots of
Small tests!!
Layouts
Widgets
• Interaction Presenters / Widget

• Creating Widgets

• Events

• Same Behaviour in each backend
• Backend API

• Widgets themselves

• Events
• How to create widgets

• Where to put them
Stop Complaining,
there are not so
many.
Common Scenarios
Different Backends
GTK
Morphic
Other
When
Test
Is
Executed
Before Opening
After Opening
Modify
Presenter
Open
Widget
Asserts
Modify
Presenter
Open
Widget Asserts
We want it
for all tests
Testing List Adapter: When I select something in the presenter it
is propagated to the widget
Only 1 Simple
Test Case
Simple /
Multiple
Selection
With / Without
Columns
Widget
Created / Not
Created
Gtk / Morphic
All this for 13
different
selection
scenarios
Only List and
Selection:
208 Tests
testSelectPresenterIndexSetsSelectedIndexInWidget
presenter selectIndex: 1.
self assert: (self widget selectedIndexes includes: 1)
Proposed Solution: Coding
Monkeys
Just Kidding,
we are lazy…
you should be
lazy also.
Implementing it with “Style”
Parametrized
Tests
Generates
when you run
the suite.
A Test
Instance for
each
combination of
parameters
Matrix of
Parameters
Our Matrix
AbstractAdapterTest class >> #testParameters 

	 ^ ParametrizedTestMatrix new

	 	 

forSelector: #specInitializationStrategy

	 	 	 addOptions: { [ SpecOpenStrategy openBefore ]. 

[ SpecOpenStrategy openAfter ] };

	 	 

forSelector: #backendForTest

	 	 	 addOptions: AbstractBackendForTest allSubclasses;

	 	 

yourself
When
Backend
We want simple tests!
testSelectItemSelectsTheGivenElement
	 self presenter selection selectedPath: #(2).

	 self assert: self adapter selectedItem equals: 2.
testSettingAnImageSetsTheImage
	 self presenter image: self imageForm.

	 backendForTest assertImage: self adapter image equals: self imageForm.
Something else required…
• Putting in the test backend backend depending code

• Adding Testing methods to the adapters & presenters
Example:
Asserting if two images are the same

#assertImage:equalsForm:
Clicking / Selecting of a widget / etc.
Example:
- Emulating Events.

- Getting State

- Accessing real widget Common API for all
backends
Results
• Lots of Tests: 1400+ and growing

• Easy To develop new ones / Easy to maintain.

• Validation of Public API

• Validation of Backend API => Easy to implement new
Backends.
Second Problem: Testing
Applications
• Easy, let’s create Tests.

• In Spec we believe, let’s test the application
Maybe Spec has problems.
But let’s create tests
where they should be.
Example Application
Phonebook
name
company
mail
telephone
PhoneEntry
*
Phonebook
Entry
Presenter
Phonebook
Presenter
initializeWidgets
	 entriesList := self newList

	 whenSelectionChangedDo: [ :sel | 

	 	 	 detailsPanel model: sel selectedItem.

	 	 	 removeButton enabled: sel isEmpty not ];

yourself.

	 addButton := self newButton

	 	 label: 'Add';

	 	 yourself.

	 removeButton := self newButton

	 	 label: 'Remove';

	 	 action: [ self removeEntry ]

	 	 yourself.

	 detailsPanel := self 

instantiate: PhonebookEntryPresenter 

on: nil.
 Details panel
Buttons
List
Testing Widgets
• Testing that a widget is shown
testWindowHasAddButton
	 self assert: (window hasPresenter: 

presenter addButton)
testAddButtonHasLabel
	 self assert: presenter addButton label equals: 'Add'
• Testing that a widget is correctly initialised
Seems stupid, but we
can test i18N here!
Testing UI State Update
• Selecting an element update the UI
testSelectingAnElementEnablesRemoveButton
	 presenter entriesList selectIndex: 1.

	 self assert: presenter removeButton isEnabled
testSelectingAnElementUpdatesDetailName
	 presenter entriesList selectIndex: 1.

	 self assert: presenter detailsPanel nameLabel label equals: 'A Person'.
Testing UI Interactions
• Clicking in Remove
testClickingRemoveButtonRemovesAnElementFromTheList
	 presenter entriesList selectIndex: 1.

	 presenter removeButton click.

	 self assert: presenter entriesList items size equals: 0
testClickingRemoveButtonRemovesDisablesRemoveButton
	 presenter entriesList selectIndex: 1.

	 presenter removeButton click.

	 self deny: presenter removeButton isEnabled
Testing UI Layout
testAddButtonIsBelowEntryList
self assert: (presenter addButton 

isBelowOf: presenter entriesList)
testAddButtonIsLeftOfRemoveButton
self assert: (presenter addButton 

isLeftOf: presenter removeButton)
Also we are able to
test dynamic things!
Testing UI Navigation
• Testing Navigation
testClickingAddButtonOpenANewWindow
	 presenter addButton click.

	 self assert: presenter application windows size equals: 2
testClickingAddButtonOpenCorrectWindow
	 presenter addButton click.

	 self 

assert: presenter application focusedPresenter class 

equals: PhonebookAddEntryPresenter
Once open… it is
responsibility of other
test to test it
Testing UI
• Spec Applications are easily testable.

• Centring on relation between our presenters.

• Spec provides methods for testing.
Thanks!
• Adding Testing infrastructure to Spec2.

• Testing implementation and backends.

• Expressing the contracts with backend as
tests.

• Open to new backend implementations.

• Support for Application Testing.

• Writing UI Tests as another easy test.
Now… without
excuses.
May the tests be
with you!

Mais conteúdo relacionado

Mais procurados

More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)Jen Wong
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in JavaMichael Fons
 
Automated Testing in Django
Automated Testing in DjangoAutomated Testing in Django
Automated Testing in DjangoLoek van Gent
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Jacinto Limjap
 
.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010kgayda
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkArulalan T
 
Simple Unit Testing With Netbeans 6.1
Simple Unit Testing With Netbeans 6.1Simple Unit Testing With Netbeans 6.1
Simple Unit Testing With Netbeans 6.1Kiki Ahmadi
 
All about unit testing using (power) mock
All about unit testing using (power) mockAll about unit testing using (power) mock
All about unit testing using (power) mockPranalee Rokde
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit TestingMike Lively
 

Mais procurados (20)

More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Tdd & unit test
Tdd & unit testTdd & unit test
Tdd & unit test
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Automated Testing in Django
Automated Testing in DjangoAutomated Testing in Django
Automated Testing in Django
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
 
Testing in Django
Testing in DjangoTesting in Django
Testing in Django
 
.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Unit tests and TDD
Unit tests and TDDUnit tests and TDD
Unit tests and TDD
 
Junit
JunitJunit
Junit
 
Unit test
Unit testUnit test
Unit test
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Mockito
MockitoMockito
Mockito
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Simple Unit Testing With Netbeans 6.1
Simple Unit Testing With Netbeans 6.1Simple Unit Testing With Netbeans 6.1
Simple Unit Testing With Netbeans 6.1
 
Grails Spock Testing
Grails Spock TestingGrails Spock Testing
Grails Spock Testing
 
All about unit testing using (power) mock
All about unit testing using (power) mockAll about unit testing using (power) mock
All about unit testing using (power) mock
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 

Semelhante a UI Testing with Spec

Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Python Testing 101 with Selenium
Python Testing 101 with SeleniumPython Testing 101 with Selenium
Python Testing 101 with SeleniumLeonardo Jimenez
 
Tdd pecha kucha_v2
Tdd pecha kucha_v2Tdd pecha kucha_v2
Tdd pecha kucha_v2Paul Boos
 
Easy Automated UI Testing with Canopy
Easy Automated UI Testing with CanopyEasy Automated UI Testing with Canopy
Easy Automated UI Testing with CanopyEric Potter
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic Peopledavismr
 
Practical unit testing tips
Practical unit testing tipsPractical unit testing tips
Practical unit testing tipsTypemock
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JSMichael Haberman
 
Describe's Full of It's
Describe's Full of It'sDescribe's Full of It's
Describe's Full of It'sJim Lynch
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django ApplicationsHonza Král
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)Amr E. Mohamed
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSJim Lynch
 
Unit Testing with Python
Unit Testing with PythonUnit Testing with Python
Unit Testing with PythonMicroPyramid .
 
Selenium ide material (2)
Selenium ide material (2)Selenium ide material (2)
Selenium ide material (2)Sriram Angajala
 

Semelhante a UI Testing with Spec (20)

Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Python Testing 101 with Selenium
Python Testing 101 with SeleniumPython Testing 101 with Selenium
Python Testing 101 with Selenium
 
Tdd pecha kucha_v2
Tdd pecha kucha_v2Tdd pecha kucha_v2
Tdd pecha kucha_v2
 
Easy Automated UI Testing with Canopy
Easy Automated UI Testing with CanopyEasy Automated UI Testing with Canopy
Easy Automated UI Testing with Canopy
 
Testing for Pragmatic People
Testing for Pragmatic PeopleTesting for Pragmatic People
Testing for Pragmatic People
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Practical unit testing tips
Practical unit testing tipsPractical unit testing tips
Practical unit testing tips
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
Describe's Full of It's
Describe's Full of It'sDescribe's Full of It's
Describe's Full of It's
 
Unit testing
Unit testingUnit testing
Unit testing
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Intro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJSIntro to Unit Testing in AngularJS
Intro to Unit Testing in AngularJS
 
Python unit testing
Python unit testingPython unit testing
Python unit testing
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Unit Testing with Python
Unit Testing with PythonUnit Testing with Python
Unit Testing with Python
 
Selenium ide material (2)
Selenium ide material (2)Selenium ide material (2)
Selenium ide material (2)
 
Unit Tesing in iOS
Unit Tesing in iOSUnit Tesing in iOS
Unit Tesing in iOS
 

Mais de Pharo

Yesplan: 10 Years later
Yesplan: 10 Years laterYesplan: 10 Years later
Yesplan: 10 Years laterPharo
 
Object-Centric Debugging: a preview
Object-Centric Debugging: a previewObject-Centric Debugging: a preview
Object-Centric Debugging: a previewPharo
 
The future of testing in Pharo
The future of testing in PharoThe future of testing in Pharo
The future of testing in PharoPharo
 
Spec 2.0: The next step on desktop UI
Spec 2.0: The next step on desktop UI Spec 2.0: The next step on desktop UI
Spec 2.0: The next step on desktop UI Pharo
 
Pharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alphaPharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alphaPharo
 
PHARO IoT: Installation Improvements and Continuous Integration
PHARO IoT: Installation Improvements and Continuous IntegrationPHARO IoT: Installation Improvements and Continuous Integration
PHARO IoT: Installation Improvements and Continuous IntegrationPharo
 
Easy REST with OpenAPI
Easy REST with OpenAPIEasy REST with OpenAPI
Easy REST with OpenAPIPharo
 
Comment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowlComment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowlPharo
 
apart Framework: Porting from VisualWorks
apart Framework: Porting from VisualWorksapart Framework: Porting from VisualWorks
apart Framework: Porting from VisualWorksPharo
 
XmppTalk
XmppTalkXmppTalk
XmppTalkPharo
 
A living programming environment for blockchain
A living programming environment for blockchainA living programming environment for blockchain
A living programming environment for blockchainPharo
 
Raspberry and Pharo
Raspberry and PharoRaspberry and Pharo
Raspberry and PharoPharo
 
Welcome: PharoDays 2017
Welcome: PharoDays 2017Welcome: PharoDays 2017
Welcome: PharoDays 2017Pharo
 
Pharo 6
Pharo 6Pharo 6
Pharo 6Pharo
 
Robotic Exploration and Mapping with Pharo
Robotic Exploration and Mapping with PharoRobotic Exploration and Mapping with Pharo
Robotic Exploration and Mapping with PharoPharo
 
Pharo 64bits
Pharo 64bitsPharo 64bits
Pharo 64bitsPharo
 
Smack: Behind the Refactorings
Smack: Behind the RefactoringsSmack: Behind the Refactorings
Smack: Behind the RefactoringsPharo
 
Pharo VM Performance
Pharo VM PerformancePharo VM Performance
Pharo VM PerformancePharo
 
Git with Style
Git with StyleGit with Style
Git with StylePharo
 
Pharo JS
Pharo JSPharo JS
Pharo JSPharo
 

Mais de Pharo (20)

Yesplan: 10 Years later
Yesplan: 10 Years laterYesplan: 10 Years later
Yesplan: 10 Years later
 
Object-Centric Debugging: a preview
Object-Centric Debugging: a previewObject-Centric Debugging: a preview
Object-Centric Debugging: a preview
 
The future of testing in Pharo
The future of testing in PharoThe future of testing in Pharo
The future of testing in Pharo
 
Spec 2.0: The next step on desktop UI
Spec 2.0: The next step on desktop UI Spec 2.0: The next step on desktop UI
Spec 2.0: The next step on desktop UI
 
Pharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alphaPharo 7.0 and 8.0 alpha
Pharo 7.0 and 8.0 alpha
 
PHARO IoT: Installation Improvements and Continuous Integration
PHARO IoT: Installation Improvements and Continuous IntegrationPHARO IoT: Installation Improvements and Continuous Integration
PHARO IoT: Installation Improvements and Continuous Integration
 
Easy REST with OpenAPI
Easy REST with OpenAPIEasy REST with OpenAPI
Easy REST with OpenAPI
 
Comment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowlComment soup with a pinch of types, served in a leaky bowl
Comment soup with a pinch of types, served in a leaky bowl
 
apart Framework: Porting from VisualWorks
apart Framework: Porting from VisualWorksapart Framework: Porting from VisualWorks
apart Framework: Porting from VisualWorks
 
XmppTalk
XmppTalkXmppTalk
XmppTalk
 
A living programming environment for blockchain
A living programming environment for blockchainA living programming environment for blockchain
A living programming environment for blockchain
 
Raspberry and Pharo
Raspberry and PharoRaspberry and Pharo
Raspberry and Pharo
 
Welcome: PharoDays 2017
Welcome: PharoDays 2017Welcome: PharoDays 2017
Welcome: PharoDays 2017
 
Pharo 6
Pharo 6Pharo 6
Pharo 6
 
Robotic Exploration and Mapping with Pharo
Robotic Exploration and Mapping with PharoRobotic Exploration and Mapping with Pharo
Robotic Exploration and Mapping with Pharo
 
Pharo 64bits
Pharo 64bitsPharo 64bits
Pharo 64bits
 
Smack: Behind the Refactorings
Smack: Behind the RefactoringsSmack: Behind the Refactorings
Smack: Behind the Refactorings
 
Pharo VM Performance
Pharo VM PerformancePharo VM Performance
Pharo VM Performance
 
Git with Style
Git with StyleGit with Style
Git with Style
 
Pharo JS
Pharo JSPharo JS
Pharo JS
 

Último

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
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
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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
 
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
 
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
 
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
 
"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
 
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
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
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
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Último (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
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
 
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
 
"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 ...
 
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
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
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
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

UI Testing with Spec

  • 1. UI Testing with Spec The future is here… hace rato! Pablo Tesone Pharo Consortium Engineer
  • 2. If it has no tests… it does not exist. Dr. Test (1987 - …)
  • 3. A little strong… but… Missing Tests Fear of Changes Unknown Impact Bad Surprises Pain… lots of pain…
  • 4. Really… If I delete something or break it… How long it will take to detect the error? We all love tests. That is easy
  • 5. We need to test the UI Testing UI is difficult We need special tools Selenium, Watir, Cypress, or Cucumber with just Objects & Polymorphism Es al pedo! j'ai la flemme!
  • 6. 2 similar but different problems. • Testing Spec implementation itself (Adapters, Presenters, Widgets, Layouts, Backends, etc) • Testing Applications written in Spec (display, interactions, update, navigations) Before Refactoring… we need tests!
  • 7. Testing Spec • Spec has a nice modular implementation, different objects with different responsibilities Presenters AdaptersLayouts Widgets • Spec is a big monster, maybe not so big… but scary… maybe not so scary:
  • 8. Testing Spec Presenters • Interaction with the Model • Events • Public API • Default Values Adapters Lots of Small tests!! Layouts Widgets • Interaction Presenters / Widget • Creating Widgets • Events • Same Behaviour in each backend • Backend API • Widgets themselves • Events • How to create widgets • Where to put them Stop Complaining, there are not so many.
  • 9. Common Scenarios Different Backends GTK Morphic Other When Test Is Executed Before Opening After Opening Modify Presenter Open Widget Asserts Modify Presenter Open Widget Asserts We want it for all tests
  • 10. Testing List Adapter: When I select something in the presenter it is propagated to the widget Only 1 Simple Test Case Simple / Multiple Selection With / Without Columns Widget Created / Not Created Gtk / Morphic All this for 13 different selection scenarios Only List and Selection: 208 Tests testSelectPresenterIndexSetsSelectedIndexInWidget presenter selectIndex: 1. self assert: (self widget selectedIndexes includes: 1)
  • 11. Proposed Solution: Coding Monkeys Just Kidding, we are lazy… you should be lazy also.
  • 12. Implementing it with “Style” Parametrized Tests Generates when you run the suite. A Test Instance for each combination of parameters Matrix of Parameters
  • 13. Our Matrix AbstractAdapterTest class >> #testParameters ^ ParametrizedTestMatrix new forSelector: #specInitializationStrategy addOptions: { [ SpecOpenStrategy openBefore ]. [ SpecOpenStrategy openAfter ] }; forSelector: #backendForTest addOptions: AbstractBackendForTest allSubclasses; yourself When Backend
  • 14. We want simple tests! testSelectItemSelectsTheGivenElement self presenter selection selectedPath: #(2). self assert: self adapter selectedItem equals: 2. testSettingAnImageSetsTheImage self presenter image: self imageForm. backendForTest assertImage: self adapter image equals: self imageForm.
  • 15. Something else required… • Putting in the test backend backend depending code • Adding Testing methods to the adapters & presenters Example: Asserting if two images are the same #assertImage:equalsForm: Clicking / Selecting of a widget / etc. Example: - Emulating Events. - Getting State - Accessing real widget Common API for all backends
  • 16. Results • Lots of Tests: 1400+ and growing • Easy To develop new ones / Easy to maintain. • Validation of Public API • Validation of Backend API => Easy to implement new Backends.
  • 17. Second Problem: Testing Applications • Easy, let’s create Tests. • In Spec we believe, let’s test the application Maybe Spec has problems. But let’s create tests where they should be.
  • 18. Example Application Phonebook name company mail telephone PhoneEntry * Phonebook Entry Presenter Phonebook Presenter initializeWidgets entriesList := self newList whenSelectionChangedDo: [ :sel | detailsPanel model: sel selectedItem. removeButton enabled: sel isEmpty not ]; yourself. addButton := self newButton label: 'Add'; yourself. removeButton := self newButton label: 'Remove'; action: [ self removeEntry ] yourself. detailsPanel := self instantiate: PhonebookEntryPresenter on: nil. Details panel Buttons List
  • 19. Testing Widgets • Testing that a widget is shown testWindowHasAddButton self assert: (window hasPresenter: presenter addButton) testAddButtonHasLabel self assert: presenter addButton label equals: 'Add' • Testing that a widget is correctly initialised Seems stupid, but we can test i18N here!
  • 20. Testing UI State Update • Selecting an element update the UI testSelectingAnElementEnablesRemoveButton presenter entriesList selectIndex: 1. self assert: presenter removeButton isEnabled testSelectingAnElementUpdatesDetailName presenter entriesList selectIndex: 1. self assert: presenter detailsPanel nameLabel label equals: 'A Person'.
  • 21. Testing UI Interactions • Clicking in Remove testClickingRemoveButtonRemovesAnElementFromTheList presenter entriesList selectIndex: 1. presenter removeButton click. self assert: presenter entriesList items size equals: 0 testClickingRemoveButtonRemovesDisablesRemoveButton presenter entriesList selectIndex: 1. presenter removeButton click. self deny: presenter removeButton isEnabled
  • 22. Testing UI Layout testAddButtonIsBelowEntryList self assert: (presenter addButton isBelowOf: presenter entriesList) testAddButtonIsLeftOfRemoveButton self assert: (presenter addButton isLeftOf: presenter removeButton) Also we are able to test dynamic things!
  • 23. Testing UI Navigation • Testing Navigation testClickingAddButtonOpenANewWindow presenter addButton click. self assert: presenter application windows size equals: 2 testClickingAddButtonOpenCorrectWindow presenter addButton click. self assert: presenter application focusedPresenter class equals: PhonebookAddEntryPresenter Once open… it is responsibility of other test to test it
  • 24. Testing UI • Spec Applications are easily testable. • Centring on relation between our presenters. • Spec provides methods for testing.
  • 25. Thanks! • Adding Testing infrastructure to Spec2. • Testing implementation and backends. • Expressing the contracts with backend as tests. • Open to new backend implementations. • Support for Application Testing. • Writing UI Tests as another easy test. Now… without excuses. May the tests be with you!