a sweet test suite
play

A Sweet Test Suite DrupalCamp Atlanta | A Sweet Test Suite | Dan - PowerPoint PPT Presentation

A Sweet Test Suite DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS A Sweet Test Sweet Dan Gurin Engineer @CivicActions Drupal Camp Asheville Organizer Twitter @dgurin dangur on github, LinkedIn, www, Slack...


  1. A Sweet Test Suite DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  2. A Sweet Test Sweet Dan Gurin Engineer @CivicActions Drupal Camp Asheville Organizer Twitter @dgurin dangur on github, LinkedIn, www, Slack... DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  3. Test Driven Development 1. Behavior-Driven Development (BDD) with Behat 2. Visual Regression Testing 3. Unit testing with PHPUnit DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  4. Behavior Driven Development with Behat Behat Drupal Extension ● Plain language ● Common scenarios ● Changes & updates ● Extensible extension DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  5. DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  6. Behavior Driven Development with Behat Tags ● Driver @api @javascript ● Groups @database @form ● Hooks ○ @beforeNodeCreate ○ @AfterScenario DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  7. Behavior Driven Development with Behat Drivers Blackbox No privileges Drush @api Can run on a different server Drupal @api More step definitions DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  8. Behavior Driven Development with Behat machine_name * Machine Name Generated by JavaScript, so without PhantonJS & @javascript, becomes an additional required field. DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  9. Behavior Driven Development with Behat Comments ● # <- Anything on a line followed by a hashtag ● Use PhpStorm? Control or Command Slash / to comment out line(s) DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  10. Behavior Driven Development with Behat Background & Tables ● Applies to all Scenarios ● Create many items DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  11. Behavior Driven Development with Behat Contexts ● Drupal - users, terms, and nodes ○ DrupalRaw - functionality ● Mink - regions and forms ● Markup - tags, classes, & attributes ● Message - notice, warning, & error ● Drush - call commands directly DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  12. Behavior Driven Development with Behat Custom Contexts FeatureContext.php file CustomContext class 1. Write the step 2. Run the test (it will fail) 3. Copy the generated snippet DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  13. Behavior Driven Development with Behat Custom Contexts DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  14. Behavior Driven Development with Behat Custom Contexts DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  15. Behavior Driven Development with Behat Custom Contexts 1. Delete exception 2. Add code 3. Test again and see if it worked DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  16. Behavior Driven Development with Behat Debugging ● Steps ○ print current url ○ print last response ● print_r($variable); DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  17. Behavior Driven Development with Behat D8 extension extension github.com/nuvoleweb/drupal-behat Autocomplete, CKEditor, Chosen, Content, Drupal, Menu, Position, Raw, Responsive, Screenshot, Select, ServiceContainer, Taxonomy, Visibility DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  18. Behavior Driven Development with Behat Sub contexts ● Contrib & Custom projects ● Modules ● Themes DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  19. Behavior Driven Development with Behat Contributing ● Behat Drupal Extension ● https://github.com/Behat/Behat/ blob/master/CONTRIBUTING.md ● http://mink.behat.org/en/latest/c ontributing.html DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  20. Test Driven Development 1. Behavior-Driven Development (BDD) with Behat 2. Visual Regression Testing 3. Unit testing with PHPUnit DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  21. Visual Regression Testing with WebdriverCSS Visual Regression Testing ● Good coverage ● Display changes ● Great for updates DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  22. Visual Regression Testing with WebdriverCSS Visual Regression Testing DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  23. Visual Regression Testing with WebdriverCSS Intersection over Union IoU DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  24. Test Driven Development 1. Behavior-Driven Development (BDD) with Behat 2. Visual Regression Testing 3. Unit testing with PHPUnit DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  25. Unit Testing with PHPUnit Drupal 8 PHPUnit Suites Name Extend State Requires Unit UnitTestCase None Code Kernel KernelTestBase Bootstrapped Database Functional BrowserTestBase Booted Webserver Javascript JavascriptTestBase Booted PhantomJS DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  26. Unit Testing with PHPUnit Unit DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  27. Unit Testing with PHPUnit Assertions ● Equals ● Same ● True / False ● PHPUnit Documentation Appendix A https://phpunit.de/manual/current/en/phpunit-book.html#appendixes.assertions DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  28. Unit Testing with PHPUnit Kernel ● Setup ● Config DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  29. Unit Testing with PHPUnit Setup ● Beginning of class ● Applies to all test functions ● Set up the parent first DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  30. Unit Testing with PHPUnit Install ● Schema ● Entity schema ● Configuration DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  31. Unit Testing with PHPUnit setUp DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  32. Unit Testing with PHPUnit Install Fields ● Get from configuration management ● Create ○ Storage ○ Field DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  33. Unit Testing with PHPUnit Enable modules DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  34. Unit Testing with PHPUnit Functional ● Enable modules ● Paths! ● Web assert DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  35. Unit Testing with PHPUnit Functional DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  36. Unit Testing with PHPUnit JavaScript ● executeScript / evaluateScript ● switchToIFrame ● keyDown ● resizeWindow ● wait DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  37. Unit Testing with PHPUnit JavascriptTestBase ● createScreenshot ● getDrupalSettings DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  38. Unit Testing with PHPUnit JavaScript Assertions ● assertElement(Not)Visible ● assertJsCondition DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  39. Unit Testing with PHPUnit assertSession ● waitFor AjaxToFinish, Button, Element(Visible), Field, Link ● waitOnAutocomplete ● responseContains ● isVisible DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  40. Unit Testing with PHPUnit Test Doubles Return a value without the object DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  41. Unit Testing with PHPUnit Mock Objects DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  42. Unit Testing with PHPUnit Traits ● Code reuse in many classes ● Groups sets of methods ● Can not be instantiated DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  43. Unit Testing with PHPUnit Reflection Trait Test protected / private methods DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  44. Unit Testing with PHPUnit Trait in action DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  45. Unit Testing with PHPUnit Data Providers ● Run same test with different datasets DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  46. Unit Testing with PHPUnit Data Providers ● Named dataset via associative array DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

  47. Unit Testing with PHPUnit Debugging ● print_r($whatEver); ● Screenshots ● Reports ● Error/failure messages DrupalCamp Atlanta | A Sweet Test Suite | Dan Gurin | @dgurin | @CIVICACTIONS

Recommend


More recommend