SlideShare ist ein Scribd-Unternehmen logo
1 von 16
PHPUnit+WebDriver
Just Sharing Knowledge
Content
•
•
•
•
•
•
•
•
•

Our Problem In Existing System
TDD
Testing with MVC
PHPUnit
PHPUnit Terms
PHPUnit Test-Case Template
WebDriver
Best Practices
How To Install
Our Problem In Existing System
Dependency
+
Maintenance

•
•
•
•

Suite Dependency.
Code-maintenance.
Testing on same Joomla-kit.
Tightly-coupled and mix up testing.
Test Driven Development
•
•

Short development cycle.
Write test case before code.
PHPUnit
Unit Test :

•
•
•

Unit testing simply verify that individual units of code work as expected.
Try to make Robust Extension.
White-box testing

Selenium/WebDriver :

•
•
•

Not unit Test case
Focus only Acceptance-Testing (Validation+Verification) and UX
Black-box testing

PHPUnit

•
•
•
•
•

Testing Framework => Unit + Integration Testing
Reports of Code-coverage (in different formats like HTML , JSON,XML format etc)
Supported DB - MySql(i), Sqlite, PostgreSql, Oracle.
Known what breaks early on and Enforces code quality.
Benefits = Automation + confidence
PHPUnit Terms..
Test-Double
Problem : Method is depends on external service/component
PHPUnit Terms..
Test-Double
Solution : Replace external service/component object and provide same API i.e Test-Double
PHPUnit Terms
Stub

•
•

Stub is simple fake object. It just makes sure test runs smoothly.
Test can’t fail.

Mock

•
•

Mock is smarter stub. You verify Your test passes through it.
Test can fail.

SPY

•

You can call object in imitation on, and after you can assert how many times it called.

Fixtures

•
•
•
•

is a “known state” for testing application.
“set up” at the start of test.
“tear down” at the end of the test.
Shares this “states” over test methods.
PHPUnit Test-Case Template
PHPUnit command-line tool prints one character to indicate progress:

•
•
•
•
•

.(Dot) – Printed when a test succeeds.
I – Printed when the test is marked as being incomplete.
S – Printed when the test has been skipped.
F – Printed when an assertion fails.
E – Printed when an error occurs while running the test.
WebDriver
WebDriver
•

WebDriver – to control the browser
o WebDriver driver = new FirefoxDriver();

•
•
•
•
•
•

WebElement – to work with the elements on the page
IE, Firefox, Chrome, Safari, Opera etc
Windows, Linux, Solaris and other OS’s
Need to create own webdriver for each test environment
Events generated are the same as for manual testing
WebDriver.TargetLocator switchTo() – switching between the popup-E, alert, windows

WebDriver-Flow
WebDriver’s Driver
•
•
•
•
•
•
•

HtmlUnit Driver
Firefox Driver
Internet Explorer Driver
Chrome Driver
Opera Driver
iPhone Driver
Android Driver
Best Practices
•
•

Every behaviour should be covered by one test.

•
•

Mock external states and services.

•
•
•

Test class name have suffix “Test” like ClassNameTest

Test one unit at a Time (follow DRY Principle)(This should force you write non-overlapping code,
break all logic into units).
Should be independent each Test-Case(test-method). But Must be independent each TestSuites(Test-class).
File name should be strtolower(ClassNameTest)
The tests are public methods and The have prefix “test” like testMethod. (You can use
annotation @test)
How to Install
Setup PHPUnit
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear install phpunit/PHP_CodeCoverage
pear install --force --alldeps phpunit/phpunit
pear channel-discover pear.symfony.com
pear install pear.symfony.com/Yaml
sudo pear install phpunit/DbUnit
sudo pear install phpunit/PHPUnit_Selenium

Setup Sqlite
sudo apt-get install php5-sqlite
Install Latest Kit
download latest sqlite configure file from http://www.sqlite.org/download.html
extract kit -> cd _NEW_EXTRACT_KIT_
./configure
sudo make install

•
•
•
•
•

Weitere ähnliche Inhalte

Was ist angesagt?

Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Applitools
 
Selenium ide made easy
Selenium ide made easySelenium ide made easy
Selenium ide made easy
Narayanan Palani
 

Was ist angesagt? (19)

Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Selenium ide made easy
Selenium ide made easySelenium ide made easy
Selenium ide made easy
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Selenium Handbook
Selenium HandbookSelenium Handbook
Selenium Handbook
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlot
 
Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011
 
Practical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test AutomationPractical Tips & Tricks for Selenium Test Automation
Practical Tips & Tricks for Selenium Test Automation
 
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlotInterview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Automated Web Testing using JavaScript
Automated Web Testing using JavaScriptAutomated Web Testing using JavaScript
Automated Web Testing using JavaScript
 
Selenium using Java
Selenium using JavaSelenium using Java
Selenium using Java
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 

Ähnlich wie PhpUnit & web driver

Agile Testing at eBay
Agile Testing at eBayAgile Testing at eBay
Agile Testing at eBay
Dominik Dary
 
Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02
Kdeepapal Mishra
 

Ähnlich wie PhpUnit & web driver (20)

Test automation proposal
Test automation proposalTest automation proposal
Test automation proposal
 
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfLesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
 
Testing Flex RIAs for NJ Flex user group
Testing Flex RIAs for NJ Flex user groupTesting Flex RIAs for NJ Flex user group
Testing Flex RIAs for NJ Flex user group
 
Tools for Software Testing
Tools for Software TestingTools for Software Testing
Tools for Software Testing
 
selenium meetup sf talk march 2014 Selenium at Scale
selenium meetup sf talk march 2014 Selenium at Scaleselenium meetup sf talk march 2014 Selenium at Scale
selenium meetup sf talk march 2014 Selenium at Scale
 
Growing Trends of Open Source UI Frameworks
Growing Trends of Open Source UI FrameworksGrowing Trends of Open Source UI Frameworks
Growing Trends of Open Source UI Frameworks
 
Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1
 
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point   automation-opensourcetestingtools_matrix-1Microsoft power point   automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
Selenium at Salesforce Scale
Selenium at Salesforce ScaleSelenium at Salesforce Scale
Selenium at Salesforce Scale
 
Salesforce selenium-saucelabs-webinar-april-2014
Salesforce selenium-saucelabs-webinar-april-2014Salesforce selenium-saucelabs-webinar-april-2014
Salesforce selenium-saucelabs-webinar-april-2014
 
Automated ui-testing
Automated ui-testingAutomated ui-testing
Automated ui-testing
 
Selenium for everyone
Selenium for everyoneSelenium for everyone
Selenium for everyone
 
Agile Testing at eBay
Agile Testing at eBayAgile Testing at eBay
Agile Testing at eBay
 
Basic Selenium Training
Basic Selenium TrainingBasic Selenium Training
Basic Selenium Training
 
Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02Selenium digitalinfobytes-120829005812-phpapp02
Selenium digitalinfobytes-120829005812-phpapp02
 
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A CookbookJavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
 
What's new in selenium 4
What's new in selenium 4What's new in selenium 4
What's new in selenium 4
 
Test parallelization using Jenkins
Test parallelization using JenkinsTest parallelization using Jenkins
Test parallelization using Jenkins
 

Kürzlich hochgeladen

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
Victor Rentea
 
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
Safe Software
 

Kürzlich hochgeladen (20)

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
 
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
 
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
 
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
 
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
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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 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 ...
 
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
 
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
 
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...
 

PhpUnit & web driver

  • 2. Content • • • • • • • • • Our Problem In Existing System TDD Testing with MVC PHPUnit PHPUnit Terms PHPUnit Test-Case Template WebDriver Best Practices How To Install
  • 3. Our Problem In Existing System Dependency + Maintenance • • • • Suite Dependency. Code-maintenance. Testing on same Joomla-kit. Tightly-coupled and mix up testing.
  • 4. Test Driven Development • • Short development cycle. Write test case before code.
  • 5.
  • 6. PHPUnit Unit Test : • • • Unit testing simply verify that individual units of code work as expected. Try to make Robust Extension. White-box testing Selenium/WebDriver : • • • Not unit Test case Focus only Acceptance-Testing (Validation+Verification) and UX Black-box testing PHPUnit • • • • • Testing Framework => Unit + Integration Testing Reports of Code-coverage (in different formats like HTML , JSON,XML format etc) Supported DB - MySql(i), Sqlite, PostgreSql, Oracle. Known what breaks early on and Enforces code quality. Benefits = Automation + confidence
  • 7. PHPUnit Terms.. Test-Double Problem : Method is depends on external service/component
  • 8. PHPUnit Terms.. Test-Double Solution : Replace external service/component object and provide same API i.e Test-Double
  • 9. PHPUnit Terms Stub • • Stub is simple fake object. It just makes sure test runs smoothly. Test can’t fail. Mock • • Mock is smarter stub. You verify Your test passes through it. Test can fail. SPY • You can call object in imitation on, and after you can assert how many times it called. Fixtures • • • • is a “known state” for testing application. “set up” at the start of test. “tear down” at the end of the test. Shares this “states” over test methods.
  • 11. PHPUnit command-line tool prints one character to indicate progress: • • • • • .(Dot) – Printed when a test succeeds. I – Printed when the test is marked as being incomplete. S – Printed when the test has been skipped. F – Printed when an assertion fails. E – Printed when an error occurs while running the test.
  • 13. WebDriver • WebDriver – to control the browser o WebDriver driver = new FirefoxDriver(); • • • • • • WebElement – to work with the elements on the page IE, Firefox, Chrome, Safari, Opera etc Windows, Linux, Solaris and other OS’s Need to create own webdriver for each test environment Events generated are the same as for manual testing WebDriver.TargetLocator switchTo() – switching between the popup-E, alert, windows WebDriver-Flow
  • 14. WebDriver’s Driver • • • • • • • HtmlUnit Driver Firefox Driver Internet Explorer Driver Chrome Driver Opera Driver iPhone Driver Android Driver
  • 15. Best Practices • • Every behaviour should be covered by one test. • • Mock external states and services. • • • Test class name have suffix “Test” like ClassNameTest Test one unit at a Time (follow DRY Principle)(This should force you write non-overlapping code, break all logic into units). Should be independent each Test-Case(test-method). But Must be independent each TestSuites(Test-class). File name should be strtolower(ClassNameTest) The tests are public methods and The have prefix “test” like testMethod. (You can use annotation @test)
  • 16. How to Install Setup PHPUnit pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear install phpunit/PHP_CodeCoverage pear install --force --alldeps phpunit/phpunit pear channel-discover pear.symfony.com pear install pear.symfony.com/Yaml sudo pear install phpunit/DbUnit sudo pear install phpunit/PHPUnit_Selenium Setup Sqlite sudo apt-get install php5-sqlite Install Latest Kit download latest sqlite configure file from http://www.sqlite.org/download.html extract kit -> cd _NEW_EXTRACT_KIT_ ./configure sudo make install • • • • •