SlideShare a Scribd company logo
Testing
Why we need to test our code (site)? Ensure security Check semantic and syntax In a small team you can track changes It can reveal bugs in a very early stage of development Environment validation Fast Permanent (not like us:( ) TDD - (later)
Testing types Unit Test PHPUnit (PHP) SimpleTest (PHP) jUnit (Java) NUnit (C#) ... Functional Test Selenium      IDE (html)      Grid (???)      Remote Control      Core Castle
Testing in common use Grouping test suites -> test tree      Optional start node Set-Up <-> Tear-Down Every single test could be a separate workflow Arbitrary extension capability (SimpleTest -> SimpleBrowserTest) Skip tests
Testing functions check if on value is...      a specific value      true      false      not null      null check if an element / object      exists      not exists      equal to ... check if an error (exception) occure check if an event triggered
Browser element properties Locators      id=___      name=___      dom=___ (javascript object)      xpath=___      link=___      css=__ Matchings      glob:___      refexp:___      exact:___ 
UnitTest sample public class UserTest extends UnitTest {      private User user;      void setUp() {          this.user = User.GetSampleUser();      }      void testUserSetName() {          this.user.setName('John Doe');          this.assertTrue(this.user.name.length > 0);          this.assertFalse(this.user.name == 'anonym');          this.assertEquals('John Doe', this.user.getName);      } }
Functional test sample public class SearchTest extends FunctionalTest {      function testFindResult() {          this.openBrowser('firefox');          this.open('http://www.example.com', 30000);          this.type(&quot;//input[@id='search-field']&quot;, &quot;Harrr&quot;);          this.click(&quot;//fieldset/input[@type=submit]&quot;);          this.waitForPageToLoad(30000);          this.assertTestPresent(&quot;regexp:\\d+ results found.*&quot;);          this.assertCookieExists('MySessionID');      } }
What you can test? Unittest:      Levels:          Function testing          Feature testing          System testing Functional test:      Page elements      Ajax jobs      Javascript
Shortcomings in testing Testing GUI appearance Complicated system actions (e.g.: in specific cases) There is no setup and teardown on test suit level It's easily became slow Browser (un)capabilities      frame / window handling      security issues (file upload)      best in FF (of course) If your code needs some conceptual change, likely your tests too Selenium sometimes collide with other JS frameworks (MooTools) UnitTest modify access to global variables, so sometimes those are unavailable
Why TDD is cool? You can fix the topmost (maybe all the) requirements Help to build a more stable software requirement Continuous code checking Prevent from writing test for code (the best: write code for the test)
Drupal and testing Drupal uses SimpleTest framework Bunch of helper to ease preparing environment for test for:      create user       login user      post node Every core module has it's own module.test file Every core.inc has it's own test in simpletest module Unfortunately Drupal's Selenium module is unsupported now
Tips and tricks Try to cover all your code with tests Don't write test depend on other tests      If one fails, it can ruin other tests (even good ones)      Without dependency, every test could be called separately Never run tests on live site (neither live database dump) You can write a script to svn that runs the test suit before commit - prevent from commiting false code

More Related Content

What's hot (20)

PDF
Unit testing best practices with JUnit
inTwentyEight Minutes
 
PPTX
Best practices unit testing
Tricode (part of Dept)
 
PPTX
Unit testing
NexThoughts Technologies
 
PPTX
Tdd & unit test
GomathiNayagam S
 
PPTX
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
PPTX
.Net Unit Testing with Visual Studio 2010
kgayda
 
PPTX
Automation test
yuyijq
 
PDF
Clean Unit Test Patterns
Frank Appel
 
PPT
J Unit
guest333f37c3
 
PPTX
Selenium TestNG
KadarkaraiSelvam
 
PPT
Simple Unit Testing With Netbeans 6.1
Kiki Ahmadi
 
PPTX
TestNG with selenium
Gousalya Ramachandran
 
PDF
How and what to unit test
Eugenio Lentini
 
PPTX
Unit Testing with Python
MicroPyramid .
 
PPT
Zend Framework 2 - PHPUnit
Tarun Kumar Singhal
 
PPTX
Unit test
Tran Duc
 
PPTX
Refactoring
Mikalai Alimenkou
 
ODP
Testing In Java
David Noble
 
PDF
Writing good unit test
Lucy Lu
 
PPTX
Testing with Junit4
Amila Paranawithana
 
Unit testing best practices with JUnit
inTwentyEight Minutes
 
Best practices unit testing
Tricode (part of Dept)
 
Tdd & unit test
GomathiNayagam S
 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
 
.Net Unit Testing with Visual Studio 2010
kgayda
 
Automation test
yuyijq
 
Clean Unit Test Patterns
Frank Appel
 
Selenium TestNG
KadarkaraiSelvam
 
Simple Unit Testing With Netbeans 6.1
Kiki Ahmadi
 
TestNG with selenium
Gousalya Ramachandran
 
How and what to unit test
Eugenio Lentini
 
Unit Testing with Python
MicroPyramid .
 
Zend Framework 2 - PHPUnit
Tarun Kumar Singhal
 
Unit test
Tran Duc
 
Refactoring
Mikalai Alimenkou
 
Testing In Java
David Noble
 
Writing good unit test
Lucy Lu
 
Testing with Junit4
Amila Paranawithana
 

Similar to Testing And Drupal (20)

PPT
Unit testing php-unit - phing - selenium_v2
Tricode (part of Dept)
 
DOCX
Test Driven Development
Anand Kumar Rajana
 
PPT
Pragmatic Parallels: Java and JavaScript
davejohnson
 
PPT
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
PPT
Unit testing
Arthur Purnama
 
PPT
Google test training
Thierry Gayet
 
PDF
Unit testing for WordPress
Harshad Mane
 
PDF
Testing Experience - Evolution of Test Automation Frameworks
Łukasz Morawski
 
PPT
Junit and testNG
Марія Русин
 
PDF
Testing Django Applications
Honza Král
 
PPT
Introduction to Selenium
rohitnayak
 
PPTX
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
PPTX
Testing with VS2010 - A Bugs Life
Peter Gfader
 
PDF
SELJE_Database_Unit_Testing_Slides.pdf
Eric Selje
 
ODP
Bring the fun back to java
ciklum_ods
 
PPS
J unit presentation
Priya Sharma
 
PPS
JUnit Presentation
priya_trivedi
 
PDF
Unit Testing on Android - Droidcon Berlin 2015
Buşra Deniz, CSM
 
PPT
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
PDF
An introduction to unit testing
Adam Stephensen
 
Unit testing php-unit - phing - selenium_v2
Tricode (part of Dept)
 
Test Driven Development
Anand Kumar Rajana
 
Pragmatic Parallels: Java and JavaScript
davejohnson
 
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
Unit testing
Arthur Purnama
 
Google test training
Thierry Gayet
 
Unit testing for WordPress
Harshad Mane
 
Testing Experience - Evolution of Test Automation Frameworks
Łukasz Morawski
 
Junit and testNG
Марія Русин
 
Testing Django Applications
Honza Král
 
Introduction to Selenium
rohitnayak
 
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Testing with VS2010 - A Bugs Life
Peter Gfader
 
SELJE_Database_Unit_Testing_Slides.pdf
Eric Selje
 
Bring the fun back to java
ciklum_ods
 
J unit presentation
Priya Sharma
 
JUnit Presentation
priya_trivedi
 
Unit Testing on Android - Droidcon Berlin 2015
Buşra Deniz, CSM
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Puneet Kala
 
An introduction to unit testing
Adam Stephensen
 
Ad

More from Peter Arato (20)

PDF
Drupal and Neo4J
Peter Arato
 
PDF
Stat diary
Peter Arato
 
PDF
Drupal contribution
Peter Arato
 
PDF
Less
Peter Arato
 
PDF
Drupal and communication
Peter Arato
 
PDF
Taste of flex
Peter Arato
 
PDF
Drupal 7 Theme System
Peter Arato
 
PDF
Drupal troubleshooting
Peter Arato
 
PDF
Drupal and testing (2010 - 2011 / 2)
Peter Arato
 
PDF
Drupal and contribution (2010 - 2011 / 2)
Peter Arato
 
KEY
Drupal Translation
Peter Arato
 
KEY
Drupal Translation
Peter Arato
 
KEY
Drupal Filters
Peter Arato
 
KEY
Drupal Multisite
Peter Arato
 
PDF
I Love Techno - the site
Peter Arato
 
PDF
Drupal Contributing
Peter Arato
 
PDF
Drupal Contribution
Peter Arato
 
PDF
How to build a Druplash site?
Peter Arato
 
PDF
Flash And Drupal
Peter Arato
 
PPT
Drupal & Flash
Peter Arato
 
Drupal and Neo4J
Peter Arato
 
Stat diary
Peter Arato
 
Drupal contribution
Peter Arato
 
Drupal and communication
Peter Arato
 
Taste of flex
Peter Arato
 
Drupal 7 Theme System
Peter Arato
 
Drupal troubleshooting
Peter Arato
 
Drupal and testing (2010 - 2011 / 2)
Peter Arato
 
Drupal and contribution (2010 - 2011 / 2)
Peter Arato
 
Drupal Translation
Peter Arato
 
Drupal Translation
Peter Arato
 
Drupal Filters
Peter Arato
 
Drupal Multisite
Peter Arato
 
I Love Techno - the site
Peter Arato
 
Drupal Contributing
Peter Arato
 
Drupal Contribution
Peter Arato
 
How to build a Druplash site?
Peter Arato
 
Flash And Drupal
Peter Arato
 
Drupal & Flash
Peter Arato
 
Ad

Recently uploaded (20)

PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 

Testing And Drupal

  • 2. Why we need to test our code (site)? Ensure security Check semantic and syntax In a small team you can track changes It can reveal bugs in a very early stage of development Environment validation Fast Permanent (not like us:( ) TDD - (later)
  • 3. Testing types Unit Test PHPUnit (PHP) SimpleTest (PHP) jUnit (Java) NUnit (C#) ... Functional Test Selenium      IDE (html)      Grid (???)      Remote Control      Core Castle
  • 4. Testing in common use Grouping test suites -> test tree      Optional start node Set-Up <-> Tear-Down Every single test could be a separate workflow Arbitrary extension capability (SimpleTest -> SimpleBrowserTest) Skip tests
  • 5. Testing functions check if on value is...      a specific value      true      false      not null      null check if an element / object      exists      not exists      equal to ... check if an error (exception) occure check if an event triggered
  • 6. Browser element properties Locators      id=___      name=___      dom=___ (javascript object)      xpath=___      link=___      css=__ Matchings      glob:___      refexp:___      exact:___ 
  • 7. UnitTest sample public class UserTest extends UnitTest {      private User user;      void setUp() {          this.user = User.GetSampleUser();      }      void testUserSetName() {          this.user.setName('John Doe');          this.assertTrue(this.user.name.length > 0);          this.assertFalse(this.user.name == 'anonym');          this.assertEquals('John Doe', this.user.getName);      } }
  • 8. Functional test sample public class SearchTest extends FunctionalTest {      function testFindResult() {          this.openBrowser('firefox');          this.open('http://www.example.com', 30000);          this.type(&quot;//input[@id='search-field']&quot;, &quot;Harrr&quot;);          this.click(&quot;//fieldset/input[@type=submit]&quot;);          this.waitForPageToLoad(30000);          this.assertTestPresent(&quot;regexp:\\d+ results found.*&quot;);          this.assertCookieExists('MySessionID');      } }
  • 9. What you can test? Unittest:      Levels:          Function testing          Feature testing          System testing Functional test:      Page elements      Ajax jobs      Javascript
  • 10. Shortcomings in testing Testing GUI appearance Complicated system actions (e.g.: in specific cases) There is no setup and teardown on test suit level It's easily became slow Browser (un)capabilities      frame / window handling      security issues (file upload)      best in FF (of course) If your code needs some conceptual change, likely your tests too Selenium sometimes collide with other JS frameworks (MooTools) UnitTest modify access to global variables, so sometimes those are unavailable
  • 11. Why TDD is cool? You can fix the topmost (maybe all the) requirements Help to build a more stable software requirement Continuous code checking Prevent from writing test for code (the best: write code for the test)
  • 12. Drupal and testing Drupal uses SimpleTest framework Bunch of helper to ease preparing environment for test for:     create user      login user     post node Every core module has it's own module.test file Every core.inc has it's own test in simpletest module Unfortunately Drupal's Selenium module is unsupported now
  • 13. Tips and tricks Try to cover all your code with tests Don't write test depend on other tests     If one fails, it can ruin other tests (even good ones)     Without dependency, every test could be called separately Never run tests on live site (neither live database dump) You can write a script to svn that runs the test suit before commit - prevent from commiting false code