SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
Testing in Drupal
        An Introduction
Who Am I?

Simon Roberts
IT Consultant,
Taniwha Solutions
Using PHP since ~1996
Using Drupal since 2005
http://drupal.org/user/33667


First used SimpleTest at Drupalcon Szeged
Testing Sprint
Who Am I?

Before the Drupalcon, I’d only had the
most casual of looks at Testing in Drupal
Have used JUnit etc previously
Was able to provide useful tests to
Drupal Core inside a couple of hours!!
You can too!
What was SimpleTest?


PHP Testing Framework
Integrated as a contributed module in
D5 + D6
Integrated in core for Drupal 7 (sortof)
Implements Automated Testing
Why Automated Testing?

Define exactly what the code should do
  Easier development
  Easier to refactor code
  Less debugging
  Less mistakes
  More fun!!
Why Automated Testing?


  Document Bugs
$xss = '<script>alert(quot;xssquot;)</script>';
$edit = array(
  'title' => $xss,
);
$node = $this->drupalCreateNode($edit);
$this->drupalGet('node/' . $node->nid . '/edit');
$this->assertNoRaw($xss, t('Harmful tags are escaped.'));
Why Automated Testing?


Document Bugs
  Prevent regressions
  Quality Assurance
  Better Software
Safety net!
Why Automated Testing?

Once a test is written, it will likely be
run many many times
Every time it is run, it verifies that the
code is still working
If it catches even one bug, it has “paid
for itself” - High value
Can be used to help reproduce problems
Testing in Drupal Core
Dries (and Drupal!) has made Testing a high priority
for Drupal 7
http://buytaert.net/drupal-7-timeline
                                                                            The actual Drupal 6 Timeline

Effective Test coverage allows us to compress the “fix”
phase of a Drupal release (code freeze)




            The Drupal 7 timeline assuming that we fully embrace testing.


Note: These dates are going to be delayed anyway - slower migration to Drupal 6
             than expected (eg: CCK, Views, Panels. drupal.org)
Not just for Drupal Core!
so... how does it work?

.test files
    Contain test classes
    Test classes extend the SimpleTest class
        well, not exactly
    Use Helper methods to:
        Simulate user actions
        Check behavior
No, really... how does it work?




 Let me show you...
What’s Left To Do?

Outstanding Testing Issues
http://drupal.org/project/issues?
projects=3060&versions=156281&components=simpletest.module,tests


“We currently have 38 tests taken out of
43 for a test coverage of 88%. This will
change when the misnamed tests are
merged.” http://groups.drupal.org/node/9408
References

Webchick’s presentation “Testing Part 1: Intro to
Testing” (Szeged Drupalcon)
http://drupal.org/simpletest
http://groups.drupal.org/testing-qa
   One SimpleTest template to rule them all
   http://groups.drupal.org/node/7731
   Drupal testing patterns
   http://groups.drupal.org/node/15190

Contenu connexe

Tendances

Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
lyricnz
 

Tendances (20)

Continuous delivery - tools and techniques
Continuous delivery - tools and techniquesContinuous delivery - tools and techniques
Continuous delivery - tools and techniques
 
Getting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalGetting Started With Jenkins And Drupal
Getting Started With Jenkins And Drupal
 
Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)Drupal Continuous Integration (European Drupal Days 2015)
Drupal Continuous Integration (European Drupal Days 2015)
 
Integration testing - A&BP CC
Integration testing - A&BP CCIntegration testing - A&BP CC
Integration testing - A&BP CC
 
Continuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CIContinuous Delivery - Automate & Build Better Software with Travis CI
Continuous Delivery - Automate & Build Better Software with Travis CI
 
Drupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - DeployDrupal Continuous Integration with Jenkins - Deploy
Drupal Continuous Integration with Jenkins - Deploy
 
Capybara testing
Capybara testingCapybara testing
Capybara testing
 
CI / CD w/ Codeception
CI / CD w/ CodeceptionCI / CD w/ Codeception
CI / CD w/ Codeception
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integration
 
DevOps 及 TDD 開發流程哲學
DevOps 及 TDD 開發流程哲學DevOps 及 TDD 開發流程哲學
DevOps 及 TDD 開發流程哲學
 
Drupalcamp Simpletest
Drupalcamp SimpletestDrupalcamp Simpletest
Drupalcamp Simpletest
 
Continuous Integration, the minimum viable product
Continuous Integration, the minimum viable productContinuous Integration, the minimum viable product
Continuous Integration, the minimum viable product
 
Midwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamMidwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small team
 
Selenium
SeleniumSelenium
Selenium
 
Principles and Practices in Continuous Deployment at Etsy
Principles and Practices in Continuous Deployment at EtsyPrinciples and Practices in Continuous Deployment at Etsy
Principles and Practices in Continuous Deployment at Etsy
 
PHPUnit with CakePHP and Yii
PHPUnit with CakePHP and YiiPHPUnit with CakePHP and Yii
PHPUnit with CakePHP and Yii
 
Composer at Scale, Release and Dependency Management
Composer at Scale, Release and Dependency ManagementComposer at Scale, Release and Dependency Management
Composer at Scale, Release and Dependency Management
 
Automation testing with Drupal 8
Automation testing with Drupal 8Automation testing with Drupal 8
Automation testing with Drupal 8
 
Put an end to regression with codeception testing
Put an end to regression with codeception testingPut an end to regression with codeception testing
Put an end to regression with codeception testing
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?
 

Similaire à Testing In Drupal

Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!
Joel Farris
 

Similaire à Testing In Drupal (20)

Simple test drupal7_presentation_la_drupal_jul21-2010
Simple test drupal7_presentation_la_drupal_jul21-2010Simple test drupal7_presentation_la_drupal_jul21-2010
Simple test drupal7_presentation_la_drupal_jul21-2010
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To Swallow
 
Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie
 
Hadoop testing workshop - july 2013
Hadoop testing workshop - july 2013Hadoop testing workshop - july 2013
Hadoop testing workshop - july 2013
 
Automated php unit testing in drupal 8
Automated php unit testing in drupal 8Automated php unit testing in drupal 8
Automated php unit testing in drupal 8
 
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
 
Automated testing in Drupal
Automated testing in DrupalAutomated testing in Drupal
Automated testing in Drupal
 
30 days or less: New Features to Production
30 days or less: New Features to Production30 days or less: New Features to Production
30 days or less: New Features to Production
 
Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1Neo4j Stored Procedure Training Part 1
Neo4j Stored Procedure Training Part 1
 
Testing practicies not only in scala
Testing practicies not only in scalaTesting practicies not only in scala
Testing practicies not only in scala
 
SynapseIndia drupal presentation on drupal info
SynapseIndia drupal  presentation on drupal infoSynapseIndia drupal  presentation on drupal info
SynapseIndia drupal presentation on drupal info
 
Hacking core
Hacking coreHacking core
Hacking core
 
Python and test
Python and testPython and test
Python and test
 
Test Driven Development with Sql Server
Test Driven Development with Sql ServerTest Driven Development with Sql Server
Test Driven Development with Sql Server
 
Test Driven Development Introduction
Test Driven Development IntroductionTest Driven Development Introduction
Test Driven Development Introduction
 
Simpletest - A beginners guide
Simpletest - A beginners guideSimpletest - A beginners guide
Simpletest - A beginners guide
 
AvenDATA and Devops
AvenDATA and DevopsAvenDATA and Devops
AvenDATA and Devops
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
Testing 101
Testing 101Testing 101
Testing 101
 

Plus de Ryan Cross

Drupal news 2012 October
Drupal news 2012 OctoberDrupal news 2012 October
Drupal news 2012 October
Ryan Cross
 
Sydney Drupal News June 2012
Sydney Drupal News June 2012Sydney Drupal News June 2012
Sydney Drupal News June 2012
Ryan Cross
 
Sydney Drupal News April 2012
Sydney Drupal News April 2012Sydney Drupal News April 2012
Sydney Drupal News April 2012
Ryan Cross
 
Sydney Drupal News August 2012
Sydney Drupal News August 2012Sydney Drupal News August 2012
Sydney Drupal News August 2012
Ryan Cross
 
Sydney Drupal News July 2012
Sydney Drupal News July 2012Sydney Drupal News July 2012
Sydney Drupal News July 2012
Ryan Cross
 
Sydney Drupal News February 2012
Sydney Drupal News February 2012Sydney Drupal News February 2012
Sydney Drupal News February 2012
Ryan Cross
 
Sydney Drupal News May 2012
Sydney Drupal News May 2012Sydney Drupal News May 2012
Sydney Drupal News May 2012
Ryan Cross
 
Sydney Drupal News September 2012
Sydney Drupal News September 2012Sydney Drupal News September 2012
Sydney Drupal News September 2012
Ryan Cross
 
Sydney Drupal News March 2012
Sydney Drupal News March 2012Sydney Drupal News March 2012
Sydney Drupal News March 2012
Ryan Cross
 
Sydney Drupal News February 2012
Sydney Drupal News February 2012Sydney Drupal News February 2012
Sydney Drupal News February 2012
Ryan Cross
 
Sydney Drupal News March 2012
Sydney Drupal News March 2012Sydney Drupal News March 2012
Sydney Drupal News March 2012
Ryan Cross
 

Plus de Ryan Cross (20)

Introduction to Content Marketing Strategy for Drupal
Introduction to Content Marketing Strategy for Drupal Introduction to Content Marketing Strategy for Drupal
Introduction to Content Marketing Strategy for Drupal
 
DrupalCon Wrap Up
DrupalCon Wrap UpDrupalCon Wrap Up
DrupalCon Wrap Up
 
Sydney Drupal News Feburary 2013
Sydney Drupal News Feburary 2013Sydney Drupal News Feburary 2013
Sydney Drupal News Feburary 2013
 
Drupal news 2012 October
Drupal news 2012 OctoberDrupal news 2012 October
Drupal news 2012 October
 
Sydney Drupal News June 2012
Sydney Drupal News June 2012Sydney Drupal News June 2012
Sydney Drupal News June 2012
 
Sydney Drupal News April 2012
Sydney Drupal News April 2012Sydney Drupal News April 2012
Sydney Drupal News April 2012
 
Sydney Drupal News August 2012
Sydney Drupal News August 2012Sydney Drupal News August 2012
Sydney Drupal News August 2012
 
Sydney Drupal News July 2012
Sydney Drupal News July 2012Sydney Drupal News July 2012
Sydney Drupal News July 2012
 
Sydney Drupal News February 2012
Sydney Drupal News February 2012Sydney Drupal News February 2012
Sydney Drupal News February 2012
 
Sydney Drupal News May 2012
Sydney Drupal News May 2012Sydney Drupal News May 2012
Sydney Drupal News May 2012
 
Sydney Drupal News September 2012
Sydney Drupal News September 2012Sydney Drupal News September 2012
Sydney Drupal News September 2012
 
Sydney Drupal News March 2012
Sydney Drupal News March 2012Sydney Drupal News March 2012
Sydney Drupal News March 2012
 
Lightning Talk: Drupal Feeds
Lightning Talk: Drupal FeedsLightning Talk: Drupal Feeds
Lightning Talk: Drupal Feeds
 
Sydney Drupal News February 2012
Sydney Drupal News February 2012Sydney Drupal News February 2012
Sydney Drupal News February 2012
 
Sydney Drupal News March 2012
Sydney Drupal News March 2012Sydney Drupal News March 2012
Sydney Drupal News March 2012
 
Drupal's Roadmap: The Magic 8 Ball
Drupal's Roadmap: The Magic 8 BallDrupal's Roadmap: The Magic 8 Ball
Drupal's Roadmap: The Magic 8 Ball
 
Converting Static Html To Drupal Theme
Converting Static Html To Drupal ThemeConverting Static Html To Drupal Theme
Converting Static Html To Drupal Theme
 
Panels 2 Demo
Panels 2 DemoPanels 2 Demo
Panels 2 Demo
 
Modify a Theme
Modify a ThemeModify a Theme
Modify a Theme
 
Drupal Basics
Drupal BasicsDrupal Basics
Drupal Basics
 

Dernier

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+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...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Testing In Drupal

  • 1. Testing in Drupal An Introduction
  • 2. Who Am I? Simon Roberts IT Consultant, Taniwha Solutions Using PHP since ~1996 Using Drupal since 2005 http://drupal.org/user/33667 First used SimpleTest at Drupalcon Szeged Testing Sprint
  • 3. Who Am I? Before the Drupalcon, I’d only had the most casual of looks at Testing in Drupal Have used JUnit etc previously Was able to provide useful tests to Drupal Core inside a couple of hours!! You can too!
  • 4. What was SimpleTest? PHP Testing Framework Integrated as a contributed module in D5 + D6 Integrated in core for Drupal 7 (sortof) Implements Automated Testing
  • 5. Why Automated Testing? Define exactly what the code should do Easier development Easier to refactor code Less debugging Less mistakes More fun!!
  • 6. Why Automated Testing? Document Bugs $xss = '<script>alert(quot;xssquot;)</script>'; $edit = array( 'title' => $xss, ); $node = $this->drupalCreateNode($edit); $this->drupalGet('node/' . $node->nid . '/edit'); $this->assertNoRaw($xss, t('Harmful tags are escaped.'));
  • 7. Why Automated Testing? Document Bugs Prevent regressions Quality Assurance Better Software Safety net!
  • 8. Why Automated Testing? Once a test is written, it will likely be run many many times Every time it is run, it verifies that the code is still working If it catches even one bug, it has “paid for itself” - High value Can be used to help reproduce problems
  • 9. Testing in Drupal Core Dries (and Drupal!) has made Testing a high priority for Drupal 7 http://buytaert.net/drupal-7-timeline The actual Drupal 6 Timeline Effective Test coverage allows us to compress the “fix” phase of a Drupal release (code freeze) The Drupal 7 timeline assuming that we fully embrace testing. Note: These dates are going to be delayed anyway - slower migration to Drupal 6 than expected (eg: CCK, Views, Panels. drupal.org)
  • 10. Not just for Drupal Core!
  • 11. so... how does it work? .test files Contain test classes Test classes extend the SimpleTest class well, not exactly Use Helper methods to: Simulate user actions Check behavior
  • 12. No, really... how does it work? Let me show you...
  • 13. What’s Left To Do? Outstanding Testing Issues http://drupal.org/project/issues? projects=3060&versions=156281&components=simpletest.module,tests “We currently have 38 tests taken out of 43 for a test coverage of 88%. This will change when the misnamed tests are merged.” http://groups.drupal.org/node/9408
  • 14. References Webchick’s presentation “Testing Part 1: Intro to Testing” (Szeged Drupalcon) http://drupal.org/simpletest http://groups.drupal.org/testing-qa One SimpleTest template to rule them all http://groups.drupal.org/node/7731 Drupal testing patterns http://groups.drupal.org/node/15190