• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Drupal 7 ci and testing
 

Drupal 7 ci and testing

on

  • 1,683 views

 

Statistics

Views

Total Views
1,683
Views on SlideShare
1,650
Embed Views
33

Actions

Likes
3
Downloads
6
Comments
1

2 Embeds 33

https://twitter.com 32
https://web.tweetdeck.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Drupal 7 ci and testing Drupal 7 ci and testing Presentation Transcript

    • Drupal 7 ContinuousIntegration and TestingSmashing Phing and Behat for fun & profit
    • Heya! |°▿▿▿▿°|/• Claudio Beatrice• @omissis• 7+ years experience in PHP• Founder of the Drupal ItaliaAssociation• Worked in Italy, France andGermany
    • So: D7, CI and TestingYeah! Nowadays it’spossible to leverage thepower of a tool or two toget a seamless continuousintegration process notmuch different to the onewe’re used to whendeveloping with lower-levelframeworks.
    • Continuous IntegrationContinuous integration (CI) is the practice, insoftware engineering, of merging all developerworkspaces with a shared mainline several times aday.- Wikipedia
    • Testing History tldrBDDCombining TDD with Domain-Driven DesignUnit testingTesting code automaticallyTDDWriting tests first
    • Agile Testing Matrixby Briack MarickAcceptanceTestingUsabilityTestingUnit TestingPerformanceTestingTechnology-facingBusiness-facingCritiqueproductSupportprogramming
    • What is that about?Basically, a collection of softwares sporting the ugliestset of icons in the known universe!
    • JenkinsJenkins is a Java application that monitors executions ofrepeated jobs, such as building a software project or jobsrun by cron.
    • JenkinsIn a nutshell, Jenkins provides an easy-to-use so-calledcontinuous integration system, making it easier fordevelopers to integrate changes to the project, andmaking it easier for users to obtain a fresh build. Theautomated, continuous build increases the productivity.
    • PhingA cross-platform build tool for PHP based on Apache AntIt offers a standard, declarative way(XML) of writingscripts to handle operations such as packaging,deploying and testing web application.It features a rich set of tasks for dealing with file systemoperations, SQL executions, code analysis and linting,documentation generation and much, much more.
    • Phing
    • DrushDrush is a command line shell and scripting interface forDrupal, a veritable Swiss Army knife designed to make lifeeasier for those of us who spend some of our workinghours hacking away at the command prompt.
    • PHPUnitIt’s the de-facto standard unit testing framework for PHP andpart of the larger xUnit family.Its primary goal is to take the smallest piece of testablesoftware in the application, isolate it from the rest of the code,and determine whether it behaves exactly as you expect.
    • PHPUnitIt provides a very useful set of tools for testing code unitssuch as:• Assertions• Fixtures• Database testing• Mock Objects• Code coverage analysis• Several kind of logging formats
    • BehatBehat is a tool for writing human-readable tests in theform of a story, using a language called Gherkin, thatdescribe the behavior of your application.By writing stories, it is possible to define acceptancecriteria that can be actually executed for testing thebehavior of a web application.
    • Ambiguity and miscommunication between developers,business owners and testers can be greatly reduced.BehatOne vocabulary to rule them all
    • BehatFeature: front pageIn order to access the websiteAs an anonymous userI need to be able to see the login formEvery feature comes with a name, followed by three linesdescribing the benefit, the role and the feature itself.This section is required but not important to Behat interms of execution, it’s just there for reading purposes.
    • BehatScenario: Login page shows the correct buttonsGiven I am on “/”Then I should not see the link “register”And I should see the link “login”And I should see the link “forgot password”Every scenario describes how a feature acts underdifferent conditions and it’s composed by three parts: thecontext, the event and the outcomeThis is the part that will be transformed into a test.
    • Behat/*** @Then /^I should not see the link "(?P<link>[^"]*)"$/*/public function iShouldNotSeeTheLink($link) {$element = $this->getSession()->getPage();$result = $element->findLink($link);if ($result) {throw new Exception(sprintf("The link %s was present on the page %s and was notsupposed to be",$link,$this->getSession()->getCurrentUrl()));}}
    • A few more little pieces...• Git, for versioning code• Drush Phing Task, for integrating Drush commands intoPhing targets• Drupal Behat extension, needed to leverage the powerof Drush into our Behat features• Migrate Module, for importing fixtures and migratingdata whenever needed• Features Module, for exporting configuration into code
    • ...and files!• .gitignore, for not tracking a good bunch of files wedon’t need• drush make, for keeping track of the modules, themesand libraries to ues• build.xml, for describing all the actions Phing will haveto take to build the website• build.ENV.properties, for storing environments variablesused during the build process• behat.yml.dist, for storing Behat’s configurations
    • Save the environment(s)!• local, the developer’s machine, where everyday work isdone.• dev, a server where the CI actually happens. It getsrebuilt from scratch and throughly tested everytime(ideally after every push on the repository)• stage, a server used to deploy “stable” dev snapshotsat a given point in time, usually for letting the clienttests on a more stable environment
    • Save the environment(s)!• debug, a copy of the production environment (asfaithful as possible), used for easily reproducing bugshappening on production and also to test deploys.• prod, the environment that hosts the final product,tuned and optimized for best performances.
    • Let’s sum up a secondJenkins takes those logs and publishes the resultsJenkins clones the repository and invokes PhingPhing performs the build of the website, upload the filesand the database and finally launches the testsPHPUnit and Behat run the testsand log the results in JUnit format
    • Time for some action!Go grab the code athttp://github.com/agavee/drupal7-base
    • You deserve some moar• http://www.slideshare.net/everzet/bdd-in-symfony2/• http://www.slideshare.net/headrevision/web-acceptance-testing-with-behat/• http://www.exampler.com/old-blog/2003/08/21/• http://www.phpunit.de/manual/current/en/index.html• http://dannorth.net/whats-in-a-story/
    • Thank you!http://silent-voice.org/http://agavee.com/@omissis