automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on...

41

Transcript of automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on...

Page 1: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance
Page 2: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

AUTOMATED ACCEPTANCE TESTING

PHP Dorset / October 2016

WITH CODECEPTION

Page 3: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

IAIN POULSON@polevaultweb

Page 4: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

IAIN POULSON@polevaultweb

https://www.meetup.com/Bournemouth-WordPress-Group/

@wpbournemouth27th October

Page 5: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

Delicious Brains

Page 6: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WP Migrate DB Pro

Page 7: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WP Migrate DB Pro WP Offload S3

Page 8: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WP Migrate DB Pro WP Offload S3

Page 9: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

THE PROBLEMReleasing a new version of one of these plugins takes time

Page 10: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WP OFFLOAD S3

Lite free plugin

Premium plugin

AWS plugin dependency

6 addon plugins

20

Manual Acceptance Test Scripts

77

81

181

3 x Developer rounds of testing with bug fixes and retests

Page 11: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT’S THE SOLUTION?

Page 12: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT’S THE SOLUTION?

Hire a tester or testers for the team

Page 13: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT’S THE SOLUTION?

Hire a tester or testers for the team

Page 14: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT’S THE SOLUTION?

Hire a tester or testers for the team

Hire the services of an external Quality Assurance team

Page 15: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT’S THE SOLUTION?

Hire a tester or testers for the team

Hire the services of an external Quality Assurance team

Page 16: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT’S THE SOLUTION?

Hire a tester or testers for the team

Hire the services of an external Quality Assurance team

Hire more developers

Page 17: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT’S THE SOLUTION?

Hire a tester or testers for the team

Hire the services of an external Quality Assurance team

Hire more developers

Page 18: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

THE EUREKA MOMENT

Page 19: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

THE EUREKA MOMENT

Rock Solid Software Testing Without Hiring an ArmyTrish Khoo

Page 20: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHY WE CAN’T HAVE NICE THINGS

Page 21: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

DO NOT HIRE A QA TEAM

The problem with this is that now you’ve got a team of people who is accountable for quality in your software and they have no power to affect the quality of it directly

Page 22: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

HER SOLUTION

AUTOMATION

Page 23: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

HER SOLUTION

AUTOMATION

The problem is that usually this is approached in a way that isn’t terribly scalable

Page 24: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

HER SOLUTION

IN-HOUSE AUTOMATION

The whole team has to commit to quality

Page 25: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WHAT DOES THAT ACTUALLY MEAN?

Page 26: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

THE PLAN

1. One developer works on replacing manual with automated tests 2. All new code should have corresponding tests written 3. Code changes should have tests updated 4. PRs should have suite of all tests run before review

Page 27: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

THE RESULT

1. Regression issues are caught much earlier 2. Release testing becomes much shorter, less labour intensive 3. Manual tests can be reduced to a skim test 4. Releases can happen more often

Page 28: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

AUTOMATE ALL THE THINGS

Page 29: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

CODECEPTIONBehaviour-driven testing framework

Built on top of PHPUnitRuns acceptance, functional, and unit tests

Page 30: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

ACCEPTANCE TESTSAcceptance tests can cover standard but complex scenarios from a user’s

perspective. With acceptance tests you can be confident that users, following all defined scenarios, won’t get errors.

http://codeception.com/docs/01-Introduction

Page 31: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

A SAMPLE TEST

Page 32: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

MODULES

Database Filesystem PhpBrowser Lots more

Page 33: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

PHPBROWSERA PHP web scraper, which acts like a browser: it sends a

request, then receives and parses the response

Page 34: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WEBDRIVER

Selenium

PhantomJS

Page 35: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

WORDPRESS INTEGRATION

WPBrowser

Extends PhpBrowser and DB Module with WordPress specific assertions

Page 36: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance
Page 37: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance
Page 38: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

TIP OF THE ICEBERG

Lots of different modules

Continous Integration

BDD support

Page 39: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

DOWNSIDES

1. Large overhead in environment setup and converting manual tests 2. Potential for customisation of modules to fit our specific needs 3. Code changes, so the tests will need to be maintained

Page 40: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

RESOURCEShttp://businessofsoftware.org/2016/06/rock-solid-software-testing-without-hiring-an-army-trish-

khoo-google-bos2015/

http://codeception.com/

https://github.com/lucatume/wp-browser

https://github.com/polevaultweb/wpos3-acceptance-testing-example

https://deliciousbrains.com/codeception-automate-wordpress-plugin-testing/

Page 41: automated acceptance testing phpdorset · CODECEPTION Behaviour-driven testing framework Built on top of PHPUnit Runs acceptance, functional, and unit tests. ACCEPTANCE TESTS Acceptance

ANY QUESTIONS?