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

PPT
Automated Unit Testing
PPT
Xp Day 080506 Unit Tests And Mocks
PDF
Unit test-using-spock in Grails
ODP
Grails unit testing
PPTX
Grails Spock Testing
PPT
How to test models using php unit testing framework?
PPTX
Introduction To J unit
PDF
Workshop unit test
Automated Unit Testing
Xp Day 080506 Unit Tests And Mocks
Unit test-using-spock in Grails
Grails unit testing
Grails Spock Testing
How to test models using php unit testing framework?
Introduction To J unit
Workshop unit test

What's hot (20)

PDF
Unit testing best practices with JUnit
PPTX
Best practices unit testing
PPTX
PPTX
Tdd & unit test
PPTX
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
PPTX
.Net Unit Testing with Visual Studio 2010
PPTX
Automation test
PDF
Clean Unit Test Patterns
PPT
PPTX
Selenium TestNG
PPT
Simple Unit Testing With Netbeans 6.1
PPTX
TestNG with selenium
PDF
How and what to unit test
PPTX
Unit Testing with Python
PPT
Zend Framework 2 - PHPUnit
PPTX
Unit test
PPTX
Refactoring
ODP
Testing In Java
PDF
Writing good unit test
PPTX
Testing with Junit4
Unit testing best practices with JUnit
Best practices unit testing
Tdd & unit test
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
.Net Unit Testing with Visual Studio 2010
Automation test
Clean Unit Test Patterns
Selenium TestNG
Simple Unit Testing With Netbeans 6.1
TestNG with selenium
How and what to unit test
Unit Testing with Python
Zend Framework 2 - PHPUnit
Unit test
Refactoring
Testing In Java
Writing good unit test
Testing with Junit4
Ad

Similar to Testing And Drupal (20)

PPTX
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
PPT
Test strategy for web development
PDF
Rethinking Testing
PDF
How the JDeveloper team test JDeveloper at UKOUG'08
PPT
Acceptance Testing With Selenium
PPT
Unit testing php-unit - phing - selenium_v2
PPTX
Unit Tests And Automated Testing
PPT
Introduction to Selenium
PPTX
Automated Testing on Web Applications
KEY
Graceful Failure with Selenium and Continuous Integration
PDF
Automated Testing in Angular Slides
PPTX
Testing 101
PDF
Intro to JavaScript Testing
DOC
Selenium course syllabus
PDF
Front-End Testing: Demystified
ZIP
Browser-Based testing using Selenium
PDF
Selenium - The Way Of Success
PDF
Android testing-with-selenium-webdriver Online Training
KEY
33rd degree
PPT
selenium.ppt
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
Test strategy for web development
Rethinking Testing
How the JDeveloper team test JDeveloper at UKOUG'08
Acceptance Testing With Selenium
Unit testing php-unit - phing - selenium_v2
Unit Tests And Automated Testing
Introduction to Selenium
Automated Testing on Web Applications
Graceful Failure with Selenium and Continuous Integration
Automated Testing in Angular Slides
Testing 101
Intro to JavaScript Testing
Selenium course syllabus
Front-End Testing: Demystified
Browser-Based testing using Selenium
Selenium - The Way Of Success
Android testing-with-selenium-webdriver Online Training
33rd degree
selenium.ppt
Ad

More from Peter Arato (20)

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

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Modernizing your data center with Dell and AMD
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
A Presentation on Artificial Intelligence
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25 Week I
Diabetes mellitus diagnosis method based random forest with bat algorithm
Modernizing your data center with Dell and AMD
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Spectral efficient network and resource selection model in 5G networks
Agricultural_Statistics_at_a_Glance_2022_0.pdf
20250228 LYD VKU AI Blended-Learning.pptx
cuic standard and advanced reporting.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
A Presentation on Artificial Intelligence

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