Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dimitris Mitsis - Automated tests with CodeCeption - WordCamp Athens 2016

Dimitris Mitsis - Automated tests with CodeCeption - WordCamp Athens 2016

WordPress Greek Community

November 19, 2016

More Decks by WordPress Greek Community

Other Decks in Programming


  1. AUTOMATED TESTING • Use of special software to compare the

    actual output of an application with the one we expect
  2. NEEDS FOR AUTOMATED TESTING • Expedite procedure of quality control

    • Quick releases • Integration with WordPress • Integration with 3rd party plugins

    tests if specific parts of the application output the expected result for a given input
  4. BENEFITS OF UNIT-TESTS • Enforce coding standards • Full awareness

    of the stack-trace Avoid phrases like: “Works but I don’t know why” White-box testing
  5. • Avoid regressions (re-appearance of the same bug) • Ensure

    that existing functionality remains • Frequency of updates SIMPLE NEEDS FOR AUTOMATED TESTING
  6. CODECEPTION • Testing framework for PHP applications • Easy and

    simple to use • Modular and extensible • Promotes design patterns
  7. Unit Tester The geek! Knows the application inside- out Functional

    Tester The tester who understands the application but has access to the interface too Acceptance Tester The user which can only test what he sees in the screen CODECEPTION Black box testing Grey box testing White box testing Integration tests
  8. INSTALLATION OF CODECEPTION Requirements • Selenium Standalone • WordPress (website)

    (locally or in server) • Browser • Composer • Phar αρχείο (executable) Installation
  9. CODECEPTION – MANUAL TEST STEPS • Create a test product

    • View product in the front-end • Add product to cart • Continue with checkout
  10. CODECEPTION – LOCATORS • CSS ID  click(“#css-id”) • CSS

    CLASS  click(“.css-class”) • TEXT  click(“Text”) • xPath  click(“//div[@xpath]”) Firebug and FirePath are your friends
  11. CODECEPTION – DESIGN PATTERNS Page Objects & Step Objects •

    Each PageObject emphasizes only on one page and its elements. • Each StepObject emphasizes on similar recurring steps
  12. CODECEPTION – PAGE OBJECTS • Locators are defined • Common

    steps associated to one page are also defined in the PageObejct • They make tests easier to read
  13. CODECEPTION – TIPS <div data-slug=”our-plugin” > // => Somewhere in

    the DOM.. //div => ...there is a ...<div>... //div[ ] => ...and it has attributes... //div[ @data-slug=’our_plugin’ ]