Slide 1

Slide 1 text

#wcAth2016 Δημήτρης Μήτσης Αυτοματοποιημένα test με το CodeCeption

Slide 2

Slide 2 text

Δημήτρης Μήτσης WPML DEVELOPMENT • QUALITY ASSURANCE • PERFORMANCE TESTING

Slide 3

Slide 3 text

AUTOMATED TESTING • Use of special software to compare the actual output of an application with the one we expect

Slide 4

Slide 4 text

Manual tests Integration tests Unit Tests

Slide 5

Slide 5 text

NEEDS FOR AUTOMATED TESTING • Expedite procedure of quality control • Quick releases • Integration with WordPress • Integration with 3rd party plugins

Slide 6

Slide 6 text

UNIT-TEST • TEST DRIVEN DEVELOPMENT (TDD) • PHPUnit Unit testing: tests if specific parts of the application output the expected result for a given input

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

2 UnitTests – 0 Integration tests

Slide 9

Slide 9 text

• Avoid regressions (re-appearance of the same bug) • Ensure that existing functionality remains • Frequency of updates SIMPLE NEEDS FOR AUTOMATED TESTING

Slide 10

Slide 10 text

UPDATES FOR WP SEO, WC & WP IN 2016

Slide 11

Slide 11 text

BEST COFFEE OF YOUR WEEK

Slide 12

Slide 12 text

CODECEPTION • Testing framework for PHP applications • Easy and simple to use • Modular and extensible • Promotes design patterns

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

INSTALLATION OF CODECEPTION Requirements • Selenium Standalone • WordPress (website) (locally or in server) • Browser • Composer • Phar αρχείο (executable) Installation

Slide 15

Slide 15 text

CODECEPTION – BOOTSTRAP $ wget http://codeception.com/codecept.phar $ php codecept.phar bootstrap

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

CODECEPTION – MANUAL TEST STEPS • Create a test product • View product in the front-end • Add product to cart • Continue with checkout

Slide 22

Slide 22 text

CODECEPTION – GENERATE TEST $ php codecept.phar generate:cept acceptance WooCommerceBasic /tests/acceptance/WooCommerceBasicCept.php

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

EMPTY CEST $ codeception.com/docs/06-ModulesAndHelpers#hooks

Slide 25

Slide 25 text

CODECEPTION – BOOTSTRAP

Slide 26

Slide 26 text

CODECEPTION –

Slide 27

Slide 27 text

CODECEPTION –

Slide 28

Slide 28 text

CODECEPTION – $

Slide 29

Slide 29 text

CODECEPTION –

Slide 30

Slide 30 text

php codecept.phar run acceptance --steps java -jar selenium-standalone.jar

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

CODECEPTION & SELENIUM IDE Two Firefox Add-ons • SeleniumIDE • CodeCeption Formatters

Slide 33

Slide 33 text

CODECEPTION HELPERS tests/_support/ΑcceptanceTester.php

Slide 34

Slide 34 text

CODECEPTION Remember to build after editing this file! php codecept.phar build

Slide 35

Slide 35 text

CODECEPTION

Slide 36

Slide 36 text

CODECEPTION – DESIGN PATTERNS Page Objects & Step Objects • Each PageObject emphasizes only on one page and its elements. • Each StepObject emphasizes on similar recurring steps

Slide 37

Slide 37 text

CODECEPTION – PAGE OBJECTS • Locators are defined • Common steps associated to one page are also defined in the PageObejct • They make tests easier to read

Slide 38

Slide 38 text

CODECEPTION php codecept.phar generate:pageobject EditProductPage

Slide 39

Slide 39 text

CODECEPTION

Slide 40

Slide 40 text

CODECEPTION

Slide 41

Slide 41 text

Q & A

Slide 42

Slide 42 text

THAT’S IT! HAPPY TESTING  TINYURL.COM/

Slide 43

Slide 43 text

CODECEPTION – LINKS

Slide 44

Slide 44 text

CODECEPTION – TIPS Link $I->click( “#start_now” );

Slide 45

Slide 45 text

CODECEPTION – TIPS
// => Somewhere in the DOM.. //div => ...there is a ...
... //div[ ] => ...and it has attributes... //div[ @data-slug=’our_plugin’ ]