SlideShare a Scribd company logo
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Because we all love to test right?
Going beyond
unit tests…
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Once upon a
time…
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
MEWebsite Twitter
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Most people
don’t write tests
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Testing should
be fun?Otherwise we won’t test our side projects
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Unit tests scare
folks…
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
So let’s not talk
about them…
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
This is not a talk
about BDD,
DDD, ATDD or
TDD Though you should check them out
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Tools, Concepts
not methodology
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
So what’s Testing
then?
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Dear client…
To Test:
Go to /form/
Enter Form Details
Click Submit & the form should submit
!
Any problems let me know!
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Dear Developer…
It doesn’t work!
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Dear client…
Did you try to clear your cache?
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
So what’s Testing
then really?
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Codeception BDD
style testing
framework
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Unit Testing, Mocking,
Functional, Acceptance
Testing, Regression
Testing and other stuff
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Acceptance
Testing
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Acceptance Testing
Codebase independent
Tests what client expects
Breaks things like a client
Easy to read and write
Can start straight away
Slow to run
Needs “live” end points
Infrastructure dependent
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Dear client…
To Test:
Go to /form/
Enter Form Details
Click Submit & the form should submit
!
Any problems let me know!
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('Fill in a form');
$I->amOnPage('/form/');
$I->see('This is a form');
$I->fillField('event', 'WordCamp London');
$I->fillField('date', '22 March 2015');
$I->fillField('where', 'London Metropolitan University');
$I->click('Save');
$I->see('Form Submitted');
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Dear client…
To Test login into the WordPress Dashboard:
Go to /wp-login.php
Enter your username and your password
Click Login & you should be redirected 

to the dashboard
!
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('Login to WordPress Admin');
$I->amOnPage('/wp-login.php');
$I->fillField('Username', 'admin');
$I->fillField('Password','password');
$I->click('Log In');
$I->see('Dashboard');
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Trying to Login to WordPress Admin (LoginCept)
Scenario:
* I am on page "/wp-login.php"
* I fill field "Username","admin"
* I fill field "Password","password"
* I click "Log In"
* I see "Dashboard"
* I click "Posts"
PASSED
php codecept.phar run acceptance --steps
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Reporting in
console, html, xml
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
WebDriver,
Selenium,
PhatomJS
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Webdriver
Pretty fast
Headless
CURL based solution
Doesn’t support javascript
User agent not always recognised
Often caught in WAFs
Enabled by default
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Selenium
Browser Automation
Supports Firefox and Chrome
Used in multiple frameworks
Can operate headless with virtual frame buffer
Bit of a pig to set up
Codeception support a Docker container to ease setup
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
PhantomJS
Headless
Supports Javascript
User agent not always recognised
Often caught in WAFs
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Functional
Testing
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Functional Testing
Like Acceptance Testing
Push data into end point
Directly call AJAX end points
No browser emulation so simple web driver
Unlike unit testing not done in isolation
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Test REST like
APIs…

WP-API Endpoints
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new ApiTester($scenario);
$I->wantTo(‘Return all posts’);
$I->sendGet(‘posts’);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContains(“content”);
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Test REST like
APIs…

RSS, ATOM Feeds
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new ApiTester($scenario);
$I->wantTo(‘Return full Feed’);
$I->sendGet(‘feed’);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeResponseContains(“channel”);
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Test cli…

WP-CLI
Commands
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new CliTester($scenario);
$I->runShellCommand(‘wp example');
$I->seeInShellOutput(‘Example List');
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Test Email…

wp_mail();
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
MailCatcher + APITester
<?php
$I = new ApiTester($scenario);
$I->wantTo(‘Return all emails’);
$I->sendGet(‘messages’);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Test XML-RPC…

Really???Well yes you can!
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new ApiTester($scenario);
$I->wantTo(‘Return XML-RPC ’);
$I->sendXMLRPCMethodCall(‘posts’);
$I->seeResponseIsXMLRPC();
$I->seeResponseContains(“posts”);
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
DBs, Factories
and tearing down
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
WP-Browserhttps://github.com/lucatume/wp-browser
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('create and check for a user');
// create a subscriber user with user login and id
$I->haveUserInDatabase('rincewind', 100);
// check for created user
$I->seeUserInDatabase(array('user_login' => 'rincewind', 'ID' => 100));
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
WP-CLI is your
friend
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Wait this is all
PHP…
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Class based Test
Suites :)
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
class exampleCEST
{
/**
* @before addPost
* @after checkFrontpage
*/
public function checkLogin(AcceptanceTester $I)
{
…
}
}
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
PageObjects &
StepObjects
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
class loginPage
{
public static $URL = ‘/wp-login.php’;
public static $usernameField = "Username";
public static $passwordField = "Password";
public static $submitButton = “Login in";
}
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
$I = new AcceptanceTester($scenario);
$I->wantTo('Login to WordPress Admin');
$I->amOnPage(loginPage::URL);
$I->fillField(loginPage::usernameField, 'admin');
$I->fillField(loginPage::passwordField,'password');
$I->click(loginPage::submitButton);
$I->see('Dashboard');
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Helpers, modules
& Addons
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
<?php
namespace CodeceptionModule;
use CodeceptionModule;
class MailCatcher extends Module
{
protected $mailcatcher;
protected $config = array('url', 'port');
!
public function _initialize()
{
$url = trim($this->config['url'], '/') . ':' . $this->config['port'];
$this->mailcatcher = new GuzzleHttpClient($url);
}
}
....
....
/**
* Messages
*
* Get an array of all the message objects
*
* @return array
* @author Jordan Eldredge <jordaneldredge@gmail.com>
**/
protected function messages()
{
$response = $this->mailcatcher->get('/messages')->send();
$messages = $response->json();
usort($messages, array($this, 'messageSortCompare'));
return $messages;
MailCatcher Module
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Debuging
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
codeception run --debug
!
$u = $foobard->haveUserInDatabase('rincewind', 100);
$this->debugSection(‘User Creation', $u);
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Alternatives?
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Multiple Test solutions out
there
PHPUnit + Selenium
Behat & Mink
Mocha
Fitness
!
many many more…
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Testing is not
just for
development
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
Automated
Testing of
Backups
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
So about those
unit tests…
COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012
TimNash.co.uk @tnash
My Stuff aka Plugs:
My Site: timnash.co.uk
My Patreon Page: patreon.com/tnash

More Related Content

Similar to Going beyond unit tests - WordCamp London 2015

Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web components
psstoev
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
myrajendra
 
CIS407AWk2iLabDefault.aspx Greetings and Salutations.docx
CIS407AWk2iLabDefault.aspx        Greetings and Salutations.docxCIS407AWk2iLabDefault.aspx        Greetings and Salutations.docx
CIS407AWk2iLabDefault.aspx Greetings and Salutations.docx
clarebernice
 
Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentation
shangbaby
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
Kiev ALT.NET
 
Introduction to angular js july 6th 2014
Introduction to angular js   july 6th 2014Introduction to angular js   july 6th 2014
Introduction to angular js july 6th 2014
Simona Clapan
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry university
lhkslkdh89009
 
What's new in ASP.NET 4
What's new in ASP.NET 4What's new in ASP.NET 4
What's new in ASP.NET 4
Robert MacLean
 
Developing PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan FrameworkDeveloping PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan Framework
Raymond Irving
 
Html 5 and css 3
Html 5 and css 3Html 5 and css 3
Html 5 and css 3
Kamalakannan Sivanandam
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
Dave Cross
 
ASP.net Manual final.pdf
ASP.net Manual final.pdfASP.net Manual final.pdf
ASP.net Manual final.pdf
SwapnilGujar13
 
SAS/Tableau integration
SAS/Tableau integrationSAS/Tableau integration
SAS/Tableau integration
Patrick Spedding
 
Creating simple php contact form
Creating simple php contact formCreating simple php contact form
Creating simple php contact form
Daniel Downs
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
COMMON Europe
 
OpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con PythonOpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con Python
PyCon Italia
 
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docxThis is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
abhi353063
 
Surfacing External Data Through Magnolia
Surfacing External Data Through MagnoliaSurfacing External Data Through Magnolia
Surfacing External Data Through Magnolia
SeanMcTex
 
asp.net - for merge.docx
asp.net - for merge.docxasp.net - for merge.docx
asp.net - for merge.docx
SwapnilGujar13
 
Getting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsGetting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial Gadgets
Atlassian
 

Similar to Going beyond unit tests - WordCamp London 2015 (20)

Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web components
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
CIS407AWk2iLabDefault.aspx Greetings and Salutations.docx
CIS407AWk2iLabDefault.aspx        Greetings and Salutations.docxCIS407AWk2iLabDefault.aspx        Greetings and Salutations.docx
CIS407AWk2iLabDefault.aspx Greetings and Salutations.docx
 
Shangz R Brown Presentation
Shangz R Brown PresentationShangz R Brown Presentation
Shangz R Brown Presentation
 
Micro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicateMicro-ORM Introduction - Don't overcomplicate
Micro-ORM Introduction - Don't overcomplicate
 
Introduction to angular js july 6th 2014
Introduction to angular js   july 6th 2014Introduction to angular js   july 6th 2014
Introduction to angular js july 6th 2014
 
Cis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry universityCis407 a ilab 5 web application development devry university
Cis407 a ilab 5 web application development devry university
 
What's new in ASP.NET 4
What's new in ASP.NET 4What's new in ASP.NET 4
What's new in ASP.NET 4
 
Developing PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan FrameworkDeveloping PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan Framework
 
Html 5 and css 3
Html 5 and css 3Html 5 and css 3
Html 5 and css 3
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
ASP.net Manual final.pdf
ASP.net Manual final.pdfASP.net Manual final.pdf
ASP.net Manual final.pdf
 
SAS/Tableau integration
SAS/Tableau integrationSAS/Tableau integration
SAS/Tableau integration
 
Creating simple php contact form
Creating simple php contact formCreating simple php contact form
Creating simple php contact form
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
OpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con PythonOpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con Python
 
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docxThis is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
This is part 1 of 3STEP 1 Modify the clsDataLayer to Use a Two-St.docx
 
Surfacing External Data Through Magnolia
Surfacing External Data Through MagnoliaSurfacing External Data Through Magnolia
Surfacing External Data Through Magnolia
 
asp.net - for merge.docx
asp.net - for merge.docxasp.net - for merge.docx
asp.net - for merge.docx
 
Getting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial GadgetsGetting the Most Out of OpenSocial Gadgets
Getting the Most Out of OpenSocial Gadgets
 

Recently uploaded

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 

Recently uploaded (20)

Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 

Going beyond unit tests - WordCamp London 2015

  • 1. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Because we all love to test right? Going beyond unit tests…
  • 2. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Once upon a time…
  • 3. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash MEWebsite Twitter
  • 4. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Most people don’t write tests
  • 5. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Testing should be fun?Otherwise we won’t test our side projects
  • 6. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Unit tests scare folks…
  • 7. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash So let’s not talk about them…
  • 8. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash This is not a talk about BDD, DDD, ATDD or TDD Though you should check them out
  • 9. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Tools, Concepts not methodology
  • 10. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash So what’s Testing then?
  • 11. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Dear client… To Test: Go to /form/ Enter Form Details Click Submit & the form should submit ! Any problems let me know!
  • 12. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Dear Developer… It doesn’t work!
  • 13. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Dear client… Did you try to clear your cache?
  • 14. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash So what’s Testing then really?
  • 15. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Codeception BDD style testing framework
  • 16. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Unit Testing, Mocking, Functional, Acceptance Testing, Regression Testing and other stuff
  • 17. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Acceptance Testing
  • 18. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Acceptance Testing Codebase independent Tests what client expects Breaks things like a client Easy to read and write Can start straight away Slow to run Needs “live” end points Infrastructure dependent
  • 19. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Dear client… To Test: Go to /form/ Enter Form Details Click Submit & the form should submit ! Any problems let me know!
  • 20. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new AcceptanceTester($scenario); $I->wantTo('Fill in a form'); $I->amOnPage('/form/'); $I->see('This is a form'); $I->fillField('event', 'WordCamp London'); $I->fillField('date', '22 March 2015'); $I->fillField('where', 'London Metropolitan University'); $I->click('Save'); $I->see('Form Submitted');
  • 21. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Dear client… To Test login into the WordPress Dashboard: Go to /wp-login.php Enter your username and your password Click Login & you should be redirected 
 to the dashboard !
  • 22. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new AcceptanceTester($scenario); $I->wantTo('Login to WordPress Admin'); $I->amOnPage('/wp-login.php'); $I->fillField('Username', 'admin'); $I->fillField('Password','password'); $I->click('Log In'); $I->see('Dashboard');
  • 23. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Trying to Login to WordPress Admin (LoginCept) Scenario: * I am on page "/wp-login.php" * I fill field "Username","admin" * I fill field "Password","password" * I click "Log In" * I see "Dashboard" * I click "Posts" PASSED php codecept.phar run acceptance --steps
  • 24. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Reporting in console, html, xml
  • 25. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash WebDriver, Selenium, PhatomJS
  • 26. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Webdriver Pretty fast Headless CURL based solution Doesn’t support javascript User agent not always recognised Often caught in WAFs Enabled by default
  • 27. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Selenium Browser Automation Supports Firefox and Chrome Used in multiple frameworks Can operate headless with virtual frame buffer Bit of a pig to set up Codeception support a Docker container to ease setup
  • 28. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash PhantomJS Headless Supports Javascript User agent not always recognised Often caught in WAFs
  • 29. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Functional Testing
  • 30. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Functional Testing Like Acceptance Testing Push data into end point Directly call AJAX end points No browser emulation so simple web driver Unlike unit testing not done in isolation
  • 31. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Test REST like APIs…
 WP-API Endpoints
  • 32. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new ApiTester($scenario); $I->wantTo(‘Return all posts’); $I->sendGet(‘posts’); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContains(“content”);
  • 33. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Test REST like APIs…
 RSS, ATOM Feeds
  • 34. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new ApiTester($scenario); $I->wantTo(‘Return full Feed’); $I->sendGet(‘feed’); $I->seeResponseCodeIs(200); $I->seeResponseIsXml(); $I->seeResponseContains(“channel”);
  • 35. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Test cli…
 WP-CLI Commands
  • 36. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new CliTester($scenario); $I->runShellCommand(‘wp example'); $I->seeInShellOutput(‘Example List');
  • 37. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Test Email…
 wp_mail();
  • 38. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash MailCatcher + APITester <?php $I = new ApiTester($scenario); $I->wantTo(‘Return all emails’); $I->sendGet(‘messages’); $I->seeResponseCodeIs(200); $I->seeResponseIsJson();
  • 39. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Test XML-RPC…
 Really???Well yes you can!
  • 40. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new ApiTester($scenario); $I->wantTo(‘Return XML-RPC ’); $I->sendXMLRPCMethodCall(‘posts’); $I->seeResponseIsXMLRPC(); $I->seeResponseContains(“posts”);
  • 41. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash DBs, Factories and tearing down
  • 42. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash WP-Browserhttps://github.com/lucatume/wp-browser
  • 43. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new AcceptanceTester($scenario); $I->wantTo('create and check for a user'); // create a subscriber user with user login and id $I->haveUserInDatabase('rincewind', 100); // check for created user $I->seeUserInDatabase(array('user_login' => 'rincewind', 'ID' => 100));
  • 44. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash WP-CLI is your friend
  • 45. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Wait this is all PHP…
  • 46. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Class based Test Suites :)
  • 47. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php class exampleCEST { /** * @before addPost * @after checkFrontpage */ public function checkLogin(AcceptanceTester $I) { … } }
  • 48. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash PageObjects & StepObjects
  • 49. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php class loginPage { public static $URL = ‘/wp-login.php’; public static $usernameField = "Username"; public static $passwordField = "Password"; public static $submitButton = “Login in"; }
  • 50. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php $I = new AcceptanceTester($scenario); $I->wantTo('Login to WordPress Admin'); $I->amOnPage(loginPage::URL); $I->fillField(loginPage::usernameField, 'admin'); $I->fillField(loginPage::passwordField,'password'); $I->click(loginPage::submitButton); $I->see('Dashboard');
  • 51. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Helpers, modules & Addons
  • 52. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash <?php namespace CodeceptionModule; use CodeceptionModule; class MailCatcher extends Module { protected $mailcatcher; protected $config = array('url', 'port'); ! public function _initialize() { $url = trim($this->config['url'], '/') . ':' . $this->config['port']; $this->mailcatcher = new GuzzleHttpClient($url); } } .... .... /** * Messages * * Get an array of all the message objects * * @return array * @author Jordan Eldredge <jordaneldredge@gmail.com> **/ protected function messages() { $response = $this->mailcatcher->get('/messages')->send(); $messages = $response->json(); usort($messages, array($this, 'messageSortCompare')); return $messages; MailCatcher Module
  • 53. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Debuging
  • 54. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash codeception run --debug ! $u = $foobard->haveUserInDatabase('rincewind', 100); $this->debugSection(‘User Creation', $u);
  • 55. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Alternatives?
  • 56. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Multiple Test solutions out there PHPUnit + Selenium Behat & Mink Mocha Fitness ! many many more…
  • 57. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Testing is not just for development
  • 58. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash Automated Testing of Backups
  • 59. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash So about those unit tests…
  • 60. COMPANY NAME PRESENTATION TITLE 12 - 12 - 2012 TimNash.co.uk @tnash My Stuff aka Plugs: My Site: timnash.co.uk My Patreon Page: patreon.com/tnash