automated testing drupalcamp in asheville

26
Automated Testing

Upload: promet-source

Post on 08-May-2015

1.232 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Automated testing DrupalCamp in Asheville

Automated Testing

Page 2: Automated testing DrupalCamp in Asheville

About Promet

Mission Statement: “Promet Solutions specializes in developing innovative, complex web applications with open source technology.”

30+ solutions architects worldwide

• Offices in the US • Chicago • San Jose

10th year in business

32 open source contributions

10+ mobile apps in the past 12 months

Page 3: Automated testing DrupalCamp in Asheville

ABOUT JOHNNIE:

• Presenter • Johnnie Fox • @johnniefox

• Promet Source • Director of Development • Scrum Master • Project Manager • Recovering Developer • @prometsource

Page 4: Automated testing DrupalCamp in Asheville

ABOUT CHRIS

• Presenter • Chris Calip

• Promet Source

• Application Developer • @prometsource

Insert picture of Chris

Page 5: Automated testing DrupalCamp in Asheville

HISTORY OF DRUPAL TESTING

Drupal Testing: D6 core – Simpletest Application specific testing - Manual Tests - Written test cases – Word documents - The spreadsheet of pain. (Checklist)

Challenges -

Testing different browsers Reproducible results Providing a record Doesn’t test integration with 3rd party API (backend functionality)

Page 6: Automated testing DrupalCamp in Asheville

CONTINUOUS INTEGRATION:

Continuous Integration (CI) implements continuous processes of applying quality control — small pieces of effort, applied frequently. Continuous integration aims to improve the quality of software, and to reduce the time taken to deliver it, by replacing the traditional practice of applying quality control after completing all development. Continuous Integration emerged in the Extreme Programming (XP) community, and XP advocates Martin Fowler and Kent Beck first wrote about continuous integration circa 1999.

Continuous integration - Wikipedia, the free encyclopedia : taken from - http://en.wikipedia.org/wiki/Continuous_integrationhttp://creativecommons.org/licenses/by-sa/3.0/

Page 7: Automated testing DrupalCamp in Asheville

HACKATHON TEAM :

Five. Striving as one. Driven by a passion for continuous automated quality control.

Ruoran Wang Scott Massey Chris Calip Johnnie Fox Michelle Krejci

Page 8: Automated testing DrupalCamp in Asheville

HACKATHON OBJECTIVE:

Develop, deploy, demonstrate, and identify challenges of making using ci infrastructure to implement acceptance tests (unit tests, selenium) on one existing site.

Page 9: Automated testing DrupalCamp in Asheville

TECHNICAL DETAILS

phpqatools.org

provisions servers with testing components

admin gui to trigger test suites, or view reports

code metrics

user acceptance

Page 10: Automated testing DrupalCamp in Asheville

Necessary components

•For necessary components and installation instructions, go to:

•Phing Drupal Template • http://reload.github.com/phing-drupal-template/ • Jenkins Drupal Template • http://reload.github.com/jenkins-drupal-template •Phing Drupal Template with User Acceptance Test • http://github.com/promet/phing-drupal-template • In addition for phing-drupal-template with user acceptance test, you need to install additional pear libraries

• For more instructions, http://phpqatools.org/

Page 11: Automated testing DrupalCamp in Asheville

Installing Infrastructure

Initial assumption: your server has several initial software already 1. Go to https://github.com/promet/phing-drupal-template 2. Three files that you need to use to install infrastructure 3. Put in on your site Drupal root 4. If you want to override it, build.properties 5. Customize variables

Page 12: Automated testing DrupalCamp in Asheville

EXAMPLE TEST SUITE FOR SITE SUPPORT

Page 13: Automated testing DrupalCamp in Asheville

Jenkins: Scheduled 1AM User

Acceptance Test Jenkins: Clone

Production to Test

PHING: Autodiscover the Selenium test

PHING: Selenium Config Upload

Done

Jenkins: If errors found, notify stakeholders

PHING: Report Generated

Jenkins & PHING: User Acceptance PHPUnit +

Selenium

PHING: Trigger each Selenium test and generate report

PHING: PHPUnit Configuration Load

PHING: Trigger each PHPUnit Test and generate report

PHING: Autodiscover the PHPUnit test

Without Bootstrap

With Bootstrap and what Bootstrap file

(ability to use Drupal API)

Page 14: Automated testing DrupalCamp in Asheville

What is Selenium?

•Selenium automates browsers. That's it. What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.

•Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.

• Goes through every page • Makes sure header, footer, logos, etc • All branding elements in place

Page 15: Automated testing DrupalCamp in Asheville

Functional Test PHPUnit

• Project Airbox • Checkout process that involves passing customer information to third party

banking API, passes back customer ID • Months after completion, API changes broke the application

• PHPUnit figures out how and where the problem is • More importantly, is there a problem?

• Major time saver for detective work • -- bootstrap option to make use of forked upal without SUT • https://github.com/chriscalip/upal • http://drupal.org/node/1567500 • actually installs a complete Drupal site like the regular Drupal installer for every test

being executed, using a random database prefix and some logic baked into Drupal's (regular runtime) core that re-routes all HTTP requests originating from WebTestBase into the "child site under test" (the db-prefixed one). Based on that, every test is able to specify additional modules to install into that child site, in order to test various combinations of modules and configuration and content/data and user input and

Page 16: Automated testing DrupalCamp in Asheville

EXAMPLE TEST SUITE FOR DEVELOPMENT SITES

Guiding principle: Fast Iteration

Page 17: Automated testing DrupalCamp in Asheville

Traditional Dev Staging Production and Workflow

Local Dev Staging Production

Manual Manual Manual

Lots of commits Significant Event (Less Frequent)

Page 18: Automated testing DrupalCamp in Asheville

Dev Staging Production Work Flow with Automated Continuous Integration Tests

Local Dev Test Branch Production

Manual Manual Manual

Run Test Suite

Staging

Automatic push if passes

Jenkins: Clone Staging DB to test DB

Jenkins: Run code-metrics test

Jenkins: Run user acceptance test

Jenkins: Run Drupal Core and Contribution Simple test

Page 19: Automated testing DrupalCamp in Asheville

Manual Test

Jenkins: Clone Staging DB to test DB (5 mins)

Jenkins: Run code-metrics test (10-15 mins)

Jenkins: Run user acceptance test (10-15 mins)

Jenkins: Run Drupal Core and Contribution Simple test (Needs work)

Jenkins: RUN ALL (35 mins)

Page 20: Automated testing DrupalCamp in Asheville

All those test eats up server resources ...

.

Page 21: Automated testing DrupalCamp in Asheville

Drupal

Sites

All

Modules

bathroom

conference room

Kitchen (Contrib)

bathroomSeleniumTest.php

bathroomUnitTest.php

conferenceroomUnitTest.php

conferenceroomSeleniumTest.php

# Chosen File Pattern by project for phpunit ie.. ExampleUnitTest.php SampleUnitTest.php project.phpunit.filepattern = UnitTest.php # Selenium # Chosen File Pattern by project for selenium ie.. ExampleSeleniumTest.php SampleSeleniumTest.php project.selenium.filepattern = SeleniumTest.php

ANATOMY OF USER ACCEPTANCE TEST ANATOMY OF USER ACCEPTANCE TEST

build.properties project.code.custom = bathroom conference_room

Page 22: Automated testing DrupalCamp in Asheville

Example Jenkins Dashboard

Page 23: Automated testing DrupalCamp in Asheville

Example of Code Metric Test PHP Mess Detector

Page 24: Automated testing DrupalCamp in Asheville

EXAMPLE OF PHPUNIT REPORT

Page 25: Automated testing DrupalCamp in Asheville

GIT POST HOOK TRIGGERING THE TEST SUITE.

Dev writes the code & test

•Dev pushes code

Client updates database • Finding a block with Selenium

http://demosource.prometdev.com/blog

Page 26: Automated testing DrupalCamp in Asheville

Questions? www.prometsource.com

[email protected] [email protected]

Twitter: @prometsource