Front-end Automated Testing #drupal-fat



Similar documents
Drupal CMS for marketing sites

JAVASCRIPT, TESTING, AND DRUPAL

DRUPAL CONTINUOUS INTEGRATION. Part I - Introduction

Headless Drupal 8. #HeadlessDrupal

Download Google Drive to windows 7

// table of contents //

Developer Documentation Revamp Proposal. Wayne Lee

Case Study: Data Recovery Raid 5

Effective unit testing with JUnit

A Baseline for Web Performance

Table of contents. HTML5 Data Bindings SEO DMXzone

Part2 Hyper-V Replica and Hyper-V Recovery Manager. Datacenter Specialist

Efficient JavaScript Unit Testing Hazem Saleh

Hudson configuration manual

Project plan. Haamuryhmä/5 Valmet Power Oy - Continual Improvement Web Tool

SENDING S & MESSAGES TO GROUPS

Show me the tests! Writing Automated Tests for Drupal

Achieving Continuous Integration with Drupal

Zoho CRM and Google Apps Synchronization

FormAPI, AJAX and Node.js

Art of Code Front-end Web Development Training Program

easy_review version BoostMyShop

HEAVY LIFTING WEB DEVELOPER

WEB BASED Access Control/Time Attendance Software Manual V 1.0

jenkins, drupal & testing automating every phing! miggle

Law School Computing Services User Memo

Certified PHP/MySQL Web Developer Course

DOCUNIZE Management System for Microsoft Office Templates

A little about me: I m a Computer Science Engineer I m Spanish but living in Finland. I ve been working and contributing to Drupal for more than 3

Website Implementation

Continuous Integration and Delivery. manage development build deploy / release

Yusof Al-Wadei Page 1 of 9. Interactive Web Design through Survey and Adoption of Modern Web-Technologies Yusof Hussein Al-Wadei

Typography and Drupal. What does Drupal provide? Ashok Modi DDCLA 2011

Customer Relationship Management Software

Get Your Project Back In Shape! How A Few Techniques Can Change Your (Project s) Life

FAA San Diego Call Center

GROWING AND MANAGING DRUPAL ORGANISATIONS. Janne Kalliola / Exove

How to Setup SQL Server Replication

Streamline your drupal development workflow in a 3-tier-environment - A story about drush make and drush aliases

Subject Tool Remarks What is JQuery. Slide Javascript Library

// table of contents //

Using IBM DevOps Services & Bluemix Services Part 2: Deploying an App that Uses a Data Management service

Embracing Eclipse Orion

Remote Viewer Recording Backup

How To Improve Your Call Center Reporting On Cms Call Center

Getting Started Configuring Your Computer Network Settings

Webform 3. Building Surveys in Drupal

Getting Started Guide

Modern Web development and operations practices. Grig Gheorghiu VP Tech Operations Nasty Gal

Microinvest Warehouse Pro Light Restaurant is designed to work in tandem with Microinvest Warehouse Pro which provides all back office functions.

Release Notes for Patch Release #2614

ServiceNow Certified Application Developer. Examination Specifications

Java course - IAG0040. Unit testing & Agile Software Development

XTM Drupal Connector. A Translation Management Tool Plugin

Improving Magento Front-End Performance

Restoring Sage Data Sage 200

Business mail 1 MS OUTLOOK CONFIGURATION... 2

Apparo Fast Edit. Excel data import via 1 / 19

NAS 259 Protecting Your Data with Remote Sync (Rsync)

// table of contents //

Modern Web Development:

How to successfully build an app with a decentralized team

PHPUnit and Drupal 8 No Unit Left Behind. Paul Mitchum

VERALAB LDAP Configuration Guide

adopting continuous delivery

DevShop. Drupal Infrastructure in a Box. Jon Pugh CEO, Founder ThinkDrop Consulting Brooklyn NY

Android App for SAP Business One. Z3moB1le App Version 1.00 Pagina 1 di 12.

// table of contents //

Magento Integration Manual (Version /24/2014)

GalleryAholic Documentation

Set up Outlook for your new student e mail with IMAP/POP3 settings

Hyperoo 2.0 A (Very) Quick Start

skype ID: store.belvg US phone number:

E-Commerce Interface Module (ECIM) User s Guide TRS Version 11

Modern CI/CD and Asset Serving

Mike Laurel. Web Developer UI / UX Engineer.

Copyright by Object Computing, Inc. (OCI). All rights reserved. AngularJS Testing

Copyright 2011 Center for Innovation in Teaching and Research 1

How to set a daily back up (WIN XP)

Friday, February 11, Bruce

CORPORATE SERVICE SETUP

Business mail 1 MS OUTLOOK RECONFIGURATION DUE TO SYSTEM MIGRATION... 2

Introduction to Module Development

How to Complete the Online Course Work for an Entry Level Clinic

How To Create A Hyperlink In Publisher On Pc Or Macbookpress.Com (Windows) On Pc/Apple) On A Pc Or Apple Powerbook (Windows 7) On Macbook Pressbook (Apple) Or Macintosh (Windows 8

Sauder Woodworking Company

CoffeeScript and Drupal. Mark Horgan

B O L T. BOLT: Streamlining Oracle Commerce Implementation and Development. Amplifi Commerce. March Copyright 2015 Amplifi Commerce.

// table of contents //

Learning Web App Development

Data Guard Remote Backup v

Bridging the Gap Between Acceptance Criteria and Definition of Done

Migration and Building of Data Centers in IBM SoftLayer with the RackWare Management Module

Automating Your Data Backup to CFAPS For Windows XP

NAS 251 Introduction to RAID

CMSC434 TUTORIAL #3 HTML CSS JavaScript Jquery Ajax + Google AppEngine Mobile WebApp HTML5

S.A.T.E.P. : Synchronous-Asynchronous Tele-education Platform

Taking Drupal development to the Cloud. Karel Bemelmans

SQL Server Setup for Assistant/Pro applications Compliance Information Systems

Abstract. Description

Transcription:

Front-end Automated Testing #drupal-fat

Ruben Teijeiro I don't know what I like more: Drupal or Beer @rteijeiro

Based on a true history...

Web Development

In collaboration with

Developers I'm ready for website development!

DevOps Almost finished setting up your server. Just one minute...

WTF!!

Designers Just redesigned the website. Now it's shinny, edgy and it pops!!

So, what?

Users In-place Content Authoring

Holy shit!!

Clients Just something And kitten like Facebook! pics. Everyone We need it loves kittens! yesterday... Better in Comic Sans Should work also in IE7

OMG!!

Browsers

Result

Front-end I said: {float: left;}!!

Solution

Refactoring Fixed Fixed Fixed Fixed Fixed Fixed Fixed

Oh man!

DEMO

BONUS!

And now I will show you how it looks like in Internet Explorer...

Now what?

FAT

Front-end Automated Testing

Because people like code that works

Continuous Integration

Push Button Receive Bacon

Unit Test

Take one tablet every git push

Automated Repeteable Easy to understand Incremental Easy to run Fast Unit Test

Testing Tools BA-K-47

Drupal 8 Modules

Drupal Modules TestSwarm https://drupal.org/project/testswarm FAT https://drupal.org/project/fat

Testing Frameworks

QUnit CasperJS PhantomJS Jasmine Testing Frameworks

TestSwarm module QUnit Tests FAT module

Bacon Module

bacon.module /** * Implements hook_testswarm_tests(). */ function bacon_testswarm_tests() { 'bacon_test' => array( 'module' => 'bacon', 'description' => 'Testing bacon.', 'js' => array( $path. '/tests/bacon.tests.js' => array(), ), 'dependencies' => array( array('testswarm', 'jquery.simulate'), ), 'path' => 'admin/bacon/test', 'permissions' => array('test bacon') ), }

tests/bacon.tests.js /*global Drupal: true, jquery: true, QUnit:true*/ (function ($, Drupal, window, document, undefined) { "use strict"; Drupal.tests.bacon = { getinfo: function() { return { name: 'Bacon test', description: 'Testing bacon.', group: 'Bacon' }; }, tests: function() { [Insert your QUnit tests here] }, }; })(jquery, Drupal, this, this.document);

Setup

tests/bacon.tests.js Drupal.tests.bacon = { getinfo: function() { return { name: 'Bacon test', description: 'Testing bacon.', group: 'Bacon' }; }, setup: function() { [Insert your setup code here] }, teardown: function() { [Insert your teardown code here] }, tests: function() { [Insert your QUnit tests here] }, };

QUnit

Assert

Assert ok(state, message) Passes if the first argument is truthy. var bbq_ready = true; QUnit.ok(bbq_ready, 'Barbecue ready!.'); var bbq_ready = false; QUnit.ok(bbq_ready, 'Barbecue ready!.');

Assert equal(actual, expected, message) Simple comparison operator (==) to compare the actual and expected arguments. var bbq = 'Bacon'; QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!'); QUnit.equal(bbq, 'Chicken', 'Chicken barbecue!');

Assert notequal(actual, expected, message) Simple inverted comparison operator (!=) to compare the actual and expected arguments. var bbq = 'Bacon'; QUnit.notEqual(bbq, 'Salad', 'No salad!'); var bbq = 'Salad'; QUnit.notEqual(bbq, 'Salad', 'No salad!');

Assert deepequal(actual, expected, message) Just like equal() when comparing objects, such that { key: value } is equal to { key: value }. var bbq = {meat: 'Bacon'}; QUnit.deepEqual(bbq, {meat: 'Bacon'}, 'Bacon barbecue!'); var bbq = {meat: 'Chicken'}; QUnit.deepEqual(bbq, {meat: 'Bacon'}, 'Bacon barbecue!');

Assert notdeepequal(actual, expected, message) Just like notequal() when comparing objects, such that { key: value } is not equal to { key: value }. var bbq = {food: 'Bacon'}; QUnit.notDeepEqual(bbq, {food: 'Salad'}, 'No salad!'); var bbq = {food: 'Salad'}; QUnit.notDeepEqual(bbq, {food: 'Salad'}, 'No salad!');

Assert strictequal(actual, expected, message) Most rigid comparison of type and value with the strict equality operator (===). var bacon = '1'; QUnit.strictEqual(bacon, '1', 'Bacon!'); QUnit.strictEqual(bacon, 1, 'Bacon!');

Assert notstrictequal(actual, expected, message) Most rigid comparison of type and value with the strict inverted equality operator (!==). var bacon = '1'; QUnit.notStrictEqual(bacon, 1, 'No Bacon!'); QUnit.notStrictEqual(bacon, '1', 'No Bacon!');

Expect

Expect expect(amount) Specify how many assertions are expected to run within a test. If the number of assertions run does not match the expected count, the test will fail. var bbq = 'Bacon'; // Good QUnit.expect(1); QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!'); // Wrong QUnit.expect(1); QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!'); QUnit.notEqual(bbq, 'Chicken', 'Chicken barbecue!');

Synchronous Testing

Synchronous Testing // Number of assertions. QUnit.expect(3); var bbq_ready = true, bbq = 'Bacon'; // Assertions. QUnit.ok(bbq_ready, 'Barbacue is ready!'); QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!'); QUnit.notEqual(bbq, 'Salad', 'No salad!');

Asynchronous Testing

Asynchronous Testing QUnit.expect(2); var bbq_ready = false, bbq = 'Bacon', time = 36000; // Miliseconds. QUnit.stop(); settimeout(function() { bbq_ready = true; QUnit.ok(bbq_ready, 'Barbacue is ready!'); QUnit.start(); }, time); QUnit.equal(bbq, 'Bacon', 'Bacon barbecue!');

Testing User Actions

Testing User Actions /** * Implements hook_testswarm_tests(). */ function bacon_testswarm_tests() { 'bacon_test' => array( 'module' => 'bacon', 'description' => 'Testing bacon.', 'js' => array( $path. '/tests/bacon.tests.js' => array(), ), 'dependencies' => array( array('testswarm', 'jquery.simulate'), ), 'path' => 'admin/bacon/test', 'permissions' => array('test bacon') ), }

Testing User Actions https://github.com/jquery/jquery-simulate QUnit.expect(1); var bbq_ready = false, bbq = 'Bacon'; bbq_ready.trigger('change'); QUnit.ok(bbq_ready, 'Barbecue ready!');

DEMO

Questions? rteijeiro@drewpull.com