SlideShare une entreprise Scribd logo
1  sur  57
Joomla! Testing
Yves Hoppe
@yveshoppe@compojoom
Why?
Deliver better and reliable application
Validate there is no regression
Make sure your application runs as expected
Trust your own application
Makes debugging much easier
Tests
In Joomla!
Unit tests
Integration tests
System tests
JavaScript tests
CodeStyle (phpcs)
Joomla! Automated Testing Team
Unit testing
In Unit testing()
we test a small and specific
amount of code
Sample method
public function isTheAnswer($number)
{
if ($number === 42)
{
return true;
}
return false;
}
Sample test
class TestCase extends PHPUnitFrameworkTestCase
{
public function testIsTheAnswer()
{
$this->assertTrue(isTheAnswer(42));
$this->assertFalse(isTheAnswer(1));
// … Best practice: One assertion per test
}
}
The issue / reality
public function getTheAnswer($number)
{
if (is_array($number))
throw new Exception('Arrays not accepted');
if (!is_numeric($number))
// Check
// Decimal, Binary, Hex - @todo add lower / upper case check
if ($number === 42 || $number === '00101010' || $number == '2A' || $number == '0x2A')
return '<span class="answer-right">The number is the answer to everything</span>';
elseif ($number == 13)
return '<div class="answer-partial">What do you get when you multiple 6 x 9=</div>';
elseif ($number == 666)
return 'WTF?!';
return false;
}
Benefits of
Unit testing
Issues can be discovered early
Acts as documentation
Forces you to write simpler and
more readable code
Verifies the design
Fastest and no GUI necessary
Drawbacks
Does not show the absence of
errors
Hard to set up useful and realistic
tests
Writing unit tests after the
development can be tough
Does only cover code
Unit tests in Joomla!
https://github.com/joomla/joomla-cms/tree/staging/tests/unit
PHPUnit 4.8.27
Within today 6119 different tests with 10526 assertions
We need you
Running the Joomla! unit tests
Clone the current staging repo from GitHub
git clone --depth 1 https://github.com/joomla/joomla-cms
Navigate with the command line to the cloned joomla instance
cd joomla-cms
Install dependencies with composer (get it before)
composer install
Run the tests with:
Value for Joomla! Extension Developers
Downsides
Complicated to set up with Joomla!
You have to mock and bootstrap everything
Lot of work
System Tests
In System Testing(Browser testing)
we test against the installed
and running application
Benefits
Tests the whole
application
Real world tests
Test more code with
less lines
System tests vs Unit tests
Unit tests are mainly used to test framework classes
System tests make sure the application works correctly from a user point
System tests does not require you to understand the code (or even the
programming language)
System tests test the whole system not only a small part
They also cover JavaScript, CSS and markup changes
System tests in Joomla!
https://www.youtube.com/watch?v=ZHo0TuA5Qjs
Google Summer of Code 2016
Prital Patel
● Setup of browser automated
tests for Joomla!
● Powered by Gherkin
● For com_users
● And com_content
Software used
https://github.com/joomla-projects/gsoc16_browser-automated-tests
Sample Codeception test
public function administratorCreateWeblink(StepAcceptanceweblink $I) {
$I->wantToTest('Weblink creation in /administrator/');
$I->doAdministratorLogin();
$I->amOnPage('administrator/index.php?option=com_weblinks');
$I->waitForText('Web Links', '30', ['css' => 'h1']);
$I->checkForPhpNoticesOrWarnings();
$I->clickToolbarButton('New');
$I->waitForText('Web Link: New', '30', ['css' => 'h1']);
$I->fillField(['id' => 'jform_title'], $this->title);
$I->fillField(['id' => 'jform_url'], $this->url);
$I->clickToolbarButton('Save & Close');
$I->waitForText('Web Links', '30', ['css' => 'h1']);
$I->see('Web link successfully saved', ['id' => 'system-message-container']);
$I->see($this->title, ['id' => 'weblinkList']);
}
Running the Joomla! Browser tests
Clone the current staging repo from GitHub
git clone --depth 1 https://github.com/joomla-projects/gsoc16_browser-
automated-tests
Navigate with the command line to the cloned instance codeception folder
cd gsoc16_browser-automated tests/tests/codeception
Install dependencies with composer (get it before)
composer install
Configure ‘tests/codeception/acceptance.suite.yml’ and run the tests with:
Value for Joomla! extension developers
Benefits
Fast to setup and you don’t need to mock Joomla!
JoomlaBrowser has common Steps for Joomla, like:
Installation, uninstallation of extensions
Navigation, Checking for PHP notices
Creating menu items
JavaScript Tests
In JavaScript Testing(Browser based)
We cover the JavaScript files
of our application.
JavaScript tests in Joomla!
Google Summer of Code 2016
Ruchiranga Wickramasinghe
● Setup of an automated test
system
● Coverage reporting
● For /media/system/js
● Tests are merged in Joomla!
Core now
Software used
Jasmine 2.4.1, Jasmine-jQuery 2.1.1, Karma 0.13.22 and Firefox 48
Within today we have 196 different tests
Running the JavaScript! tests
Clone the current staging repo from GitHub
git clone --depth 1 https://github.com/joomla/joomla-cms
Navigate with the command line to your joomla instance javascript tests folder
cd joomla-cms/tests/javascript
Install dependencies with npm (get it before)
npm install
Run the tests with:
Value for Joomla! Extension Developers
Benefits
No need for mocking Joomla!
No running Joomla! Installation needed
Easy to write and setup
CodeStyle tests
Code Style
and Metrics tests(Static Analysis)
check .
Why Code Style
matters
Communication is the Key
Code looks consistent
Clear rules for developers
Make Errors obvious
Code Style in Joomla!
http://joomla.github.io/coding-standards/
PHP_CodeSniffer
(phpcs)
and PHPQA Tools
PHP_CodeSniffer 1.5.6 (working on upgrade)
Running the PHP_CodeSniffer checks
Clone the current staging repo from GitHub
git clone --depth 1 https://github.com/joomla/joomla-cms
Navigate with the command line to your joomla instance
cd joomla-cms
Install dependencies with composer (get it before)
composer install
Run the tests with:
Automated testing
Putting the tests
together to a big
automatic safety net!
Why?
Repeatable
Detect issues for every commit / pull request
Saves you time and money
Automated tests in Joomla!
Software used
Directly see issues at your Pull Request
Runs for every change and pull request against core
Travis:
Multiple PHP Versions:
- PHP 5.3, 5.4, 5.5, 5.6, 7.0
- 7.1, HHVM (allowed to fail)
JavaScript tests (Node.js)
PHP_CodeSniffer (PHP 5.6)
Conclusion
Call for volunteers!
The Joomla! Automated Testing Working Group is looking for
new members, which want to make Joomla! better
https://volunteers.joomla.org/teams/automated-tests-working-group
Questions?
Thank you for listening!
@yveshoppe

Contenu connexe

Tendances

DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...
DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...
DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...Dakiry
 
Test automation
Test automationTest automation
Test automationXavier Yin
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven TestingMaveryx
 
Keyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkKeyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkMikhail Subach
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Applitools
 
Full Testing Experience - Visual Studio and TFS 2010
 Full Testing Experience - Visual Studio and TFS 2010 Full Testing Experience - Visual Studio and TFS 2010
Full Testing Experience - Visual Studio and TFS 2010Ed Blankenship
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
Selenium notes
Selenium notesSelenium notes
Selenium noteswholcomb
 
Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test CompleteVartika Saxena
 
Illia Seleznov - Integration tests for Spring Boot application
Illia Seleznov - Integration tests for Spring Boot applicationIllia Seleznov - Integration tests for Spring Boot application
Illia Seleznov - Integration tests for Spring Boot applicationAnna Shymchenko
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Hazem Saleh
 
Automation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterAutomation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterVijayChowthri Nagaprakasham
 
Final Automation Testing
Final Automation TestingFinal Automation Testing
Final Automation Testingpriya_trivedi
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_completebinuiweb
 
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail Keytorc Software Testing Services
 

Tendances (20)

DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...
DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...
DaKiRY_BAQ2016_QADay_Marta Firlej "Microsoft Test Manager tool – how can we u...
 
Qa process
Qa processQa process
Qa process
 
Test automation
Test automationTest automation
Test automation
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
 
Keyword-driven Test Automation Framework
Keyword-driven Test Automation FrameworkKeyword-driven Test Automation Framework
Keyword-driven Test Automation Framework
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
 
Full Testing Experience - Visual Studio and TFS 2010
 Full Testing Experience - Visual Studio and TFS 2010 Full Testing Experience - Visual Studio and TFS 2010
Full Testing Experience - Visual Studio and TFS 2010
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
Selenium notes
Selenium notesSelenium notes
Selenium notes
 
Test complete, work done so far
Test complete, work done so farTest complete, work done so far
Test complete, work done so far
 
Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test Complete
 
Automation Framework/QTP Framework
Automation Framework/QTP FrameworkAutomation Framework/QTP Framework
Automation Framework/QTP Framework
 
Illia Seleznov - Integration tests for Spring Boot application
Illia Seleznov - Integration tests for Spring Boot applicationIllia Seleznov - Integration tests for Spring Boot application
Illia Seleznov - Integration tests for Spring Boot application
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013
 
Automation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional TesterAutomation testing IBM RFT - Rational Functional Tester
Automation testing IBM RFT - Rational Functional Tester
 
Final Automation Testing
Final Automation TestingFinal Automation Testing
Final Automation Testing
 
Test Complete
Test CompleteTest Complete
Test Complete
 
The Fitnesse Fix
The Fitnesse FixThe Fitnesse Fix
The Fitnesse Fix
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_complete
 
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail
 

En vedette

Saudi Arabia’s National Open Education Strategy, Master Plan & Policy
Saudi Arabia’s National Open Education Strategy, Master Plan & PolicySaudi Arabia’s National Open Education Strategy, Master Plan & Policy
Saudi Arabia’s National Open Education Strategy, Master Plan & PolicyCable Green
 
Made With Creative Commons
Made With Creative CommonsMade With Creative Commons
Made With Creative CommonsPaul_Stacey
 
Creative Commons Certificates
Creative Commons CertificatesCreative Commons Certificates
Creative Commons CertificatesPaul_Stacey
 
Third Mission of Universities, MOOCs and OERs
Third Mission of Universities, MOOCs and OERsThird Mission of Universities, MOOCs and OERs
Third Mission of Universities, MOOCs and OERsOpen Education Consortium
 
Mainstreaming OER in Support of Achieving SDG4
Mainstreaming OER in Support of Achieving SDG4Mainstreaming OER in Support of Achieving SDG4
Mainstreaming OER in Support of Achieving SDG4Cable Green
 
Building a more open, collaborative CC global movement
Building a more open, collaborative CC global movementBuilding a more open, collaborative CC global movement
Building a more open, collaborative CC global movementOpen Education Consortium
 

En vedette (8)

Open Credential and Radical Openness
 Open Credential  and Radical Openness Open Credential  and Radical Openness
Open Credential and Radical Openness
 
Saudi Arabia’s National Open Education Strategy, Master Plan & Policy
Saudi Arabia’s National Open Education Strategy, Master Plan & PolicySaudi Arabia’s National Open Education Strategy, Master Plan & Policy
Saudi Arabia’s National Open Education Strategy, Master Plan & Policy
 
Made With Creative Commons
Made With Creative CommonsMade With Creative Commons
Made With Creative Commons
 
Creative Commons Certificates
Creative Commons CertificatesCreative Commons Certificates
Creative Commons Certificates
 
Third Mission of Universities, MOOCs and OERs
Third Mission of Universities, MOOCs and OERsThird Mission of Universities, MOOCs and OERs
Third Mission of Universities, MOOCs and OERs
 
Mainstreaming OER in Support of Achieving SDG4
Mainstreaming OER in Support of Achieving SDG4Mainstreaming OER in Support of Achieving SDG4
Mainstreaming OER in Support of Achieving SDG4
 
Building a more open, collaborative CC global movement
Building a more open, collaborative CC global movementBuilding a more open, collaborative CC global movement
Building a more open, collaborative CC global movement
 
Minicurso de CKAN
Minicurso de CKANMinicurso de CKAN
Minicurso de CKAN
 

Similaire à Why Automated Testing is Important for Joomla! Extensions

Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPressHarshad Mane
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsQuontra Solutions
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choicetoddbr
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Joe Ferguson
 
Lightning Talks by Globant - Automation (This app runs by itself )
Lightning Talks by Globant -  Automation (This app runs by itself ) Lightning Talks by Globant -  Automation (This app runs by itself )
Lightning Talks by Globant - Automation (This app runs by itself ) Globant
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis Engineering Software Lab
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptx
OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptxOS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptx
OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptxShivareddyGangam
 
Creating testing tools to support development
Creating testing tools to support developmentCreating testing tools to support development
Creating testing tools to support developmentChema del Barco
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialJAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialAnup Singh
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeAleksandar Bozinovski
 
Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015Stephen Ritchie
 
Automation testing
Automation testingAutomation testing
Automation testingTomy Rhymond
 

Similaire à Why Automated Testing is Important for Joomla! Extensions (20)

Unit testing for WordPress
Unit testing for WordPressUnit testing for WordPress
Unit testing for WordPress
 
Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
 
Test
TestTest
Test
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015
 
Lightning Talks by Globant - Automation (This app runs by itself )
Lightning Talks by Globant -  Automation (This app runs by itself ) Lightning Talks by Globant -  Automation (This app runs by itself )
Lightning Talks by Globant - Automation (This app runs by itself )
 
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
Parasoft .TEST, Write better C# Code Using  Data Flow Analysis Parasoft .TEST, Write better C# Code Using  Data Flow Analysis
Parasoft .TEST, Write better C# Code Using Data Flow Analysis
 
Codeception
CodeceptionCodeception
Codeception
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptx
OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptxOS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptx
OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptx
 
Creating testing tools to support development
Creating testing tools to support developmentCreating testing tools to support development
Creating testing tools to support development
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialJAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable Code
 
Unit Tests with Microsoft Fakes
Unit Tests with Microsoft FakesUnit Tests with Microsoft Fakes
Unit Tests with Microsoft Fakes
 
Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015
 
Automation testing
Automation testingAutomation testing
Automation testing
 

Dernier

Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdfAkritiPradhan2
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfBalamuruganV28
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsapna80328
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosVictor Morales
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewsandhya757531
 

Dernier (20)

Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
CS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdfCS 3251 Programming in c all unit notes pdf
CS 3251 Programming in c all unit notes pdf
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveying
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
KCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitosKCD Costa Rica 2024 - Nephio para parvulitos
KCD Costa Rica 2024 - Nephio para parvulitos
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overview
 

Why Automated Testing is Important for Joomla! Extensions

  • 2. Why? Deliver better and reliable application Validate there is no regression Make sure your application runs as expected Trust your own application Makes debugging much easier
  • 3. Tests In Joomla! Unit tests Integration tests System tests JavaScript tests CodeStyle (phpcs)
  • 6. In Unit testing() we test a small and specific amount of code
  • 7. Sample method public function isTheAnswer($number) { if ($number === 42) { return true; } return false; }
  • 8. Sample test class TestCase extends PHPUnitFrameworkTestCase { public function testIsTheAnswer() { $this->assertTrue(isTheAnswer(42)); $this->assertFalse(isTheAnswer(1)); // … Best practice: One assertion per test } }
  • 9. The issue / reality public function getTheAnswer($number) { if (is_array($number)) throw new Exception('Arrays not accepted'); if (!is_numeric($number)) // Check // Decimal, Binary, Hex - @todo add lower / upper case check if ($number === 42 || $number === '00101010' || $number == '2A' || $number == '0x2A') return '<span class="answer-right">The number is the answer to everything</span>'; elseif ($number == 13) return '<div class="answer-partial">What do you get when you multiple 6 x 9=</div>'; elseif ($number == 666) return 'WTF?!'; return false; }
  • 10. Benefits of Unit testing Issues can be discovered early Acts as documentation Forces you to write simpler and more readable code Verifies the design Fastest and no GUI necessary
  • 11. Drawbacks Does not show the absence of errors Hard to set up useful and realistic tests Writing unit tests after the development can be tough Does only cover code
  • 12. Unit tests in Joomla!
  • 14. PHPUnit 4.8.27 Within today 6119 different tests with 10526 assertions
  • 16. Running the Joomla! unit tests Clone the current staging repo from GitHub git clone --depth 1 https://github.com/joomla/joomla-cms Navigate with the command line to the cloned joomla instance cd joomla-cms Install dependencies with composer (get it before) composer install Run the tests with:
  • 17. Value for Joomla! Extension Developers
  • 18. Downsides Complicated to set up with Joomla! You have to mock and bootstrap everything Lot of work
  • 20. In System Testing(Browser testing) we test against the installed and running application
  • 21. Benefits Tests the whole application Real world tests Test more code with less lines
  • 22. System tests vs Unit tests Unit tests are mainly used to test framework classes System tests make sure the application works correctly from a user point System tests does not require you to understand the code (or even the programming language) System tests test the whole system not only a small part They also cover JavaScript, CSS and markup changes
  • 23. System tests in Joomla! https://www.youtube.com/watch?v=ZHo0TuA5Qjs
  • 24. Google Summer of Code 2016 Prital Patel ● Setup of browser automated tests for Joomla! ● Powered by Gherkin ● For com_users ● And com_content
  • 25.
  • 28. Sample Codeception test public function administratorCreateWeblink(StepAcceptanceweblink $I) { $I->wantToTest('Weblink creation in /administrator/'); $I->doAdministratorLogin(); $I->amOnPage('administrator/index.php?option=com_weblinks'); $I->waitForText('Web Links', '30', ['css' => 'h1']); $I->checkForPhpNoticesOrWarnings(); $I->clickToolbarButton('New'); $I->waitForText('Web Link: New', '30', ['css' => 'h1']); $I->fillField(['id' => 'jform_title'], $this->title); $I->fillField(['id' => 'jform_url'], $this->url); $I->clickToolbarButton('Save & Close'); $I->waitForText('Web Links', '30', ['css' => 'h1']); $I->see('Web link successfully saved', ['id' => 'system-message-container']); $I->see($this->title, ['id' => 'weblinkList']); }
  • 29. Running the Joomla! Browser tests Clone the current staging repo from GitHub git clone --depth 1 https://github.com/joomla-projects/gsoc16_browser- automated-tests Navigate with the command line to the cloned instance codeception folder cd gsoc16_browser-automated tests/tests/codeception Install dependencies with composer (get it before) composer install Configure ‘tests/codeception/acceptance.suite.yml’ and run the tests with:
  • 30. Value for Joomla! extension developers
  • 31. Benefits Fast to setup and you don’t need to mock Joomla! JoomlaBrowser has common Steps for Joomla, like: Installation, uninstallation of extensions Navigation, Checking for PHP notices Creating menu items
  • 33. In JavaScript Testing(Browser based) We cover the JavaScript files of our application.
  • 35. Google Summer of Code 2016 Ruchiranga Wickramasinghe ● Setup of an automated test system ● Coverage reporting ● For /media/system/js ● Tests are merged in Joomla! Core now
  • 37. Jasmine 2.4.1, Jasmine-jQuery 2.1.1, Karma 0.13.22 and Firefox 48 Within today we have 196 different tests
  • 38. Running the JavaScript! tests Clone the current staging repo from GitHub git clone --depth 1 https://github.com/joomla/joomla-cms Navigate with the command line to your joomla instance javascript tests folder cd joomla-cms/tests/javascript Install dependencies with npm (get it before) npm install Run the tests with:
  • 39. Value for Joomla! Extension Developers
  • 40. Benefits No need for mocking Joomla! No running Joomla! Installation needed Easy to write and setup
  • 42. Code Style and Metrics tests(Static Analysis) check .
  • 43. Why Code Style matters Communication is the Key Code looks consistent Clear rules for developers Make Errors obvious
  • 44. Code Style in Joomla! http://joomla.github.io/coding-standards/ PHP_CodeSniffer (phpcs) and PHPQA Tools
  • 46. Running the PHP_CodeSniffer checks Clone the current staging repo from GitHub git clone --depth 1 https://github.com/joomla/joomla-cms Navigate with the command line to your joomla instance cd joomla-cms Install dependencies with composer (get it before) composer install Run the tests with:
  • 48. Putting the tests together to a big automatic safety net!
  • 49.
  • 50. Why? Repeatable Detect issues for every commit / pull request Saves you time and money
  • 53. Directly see issues at your Pull Request
  • 54. Runs for every change and pull request against core Travis: Multiple PHP Versions: - PHP 5.3, 5.4, 5.5, 5.6, 7.0 - 7.1, HHVM (allowed to fail) JavaScript tests (Node.js) PHP_CodeSniffer (PHP 5.6)
  • 56. Call for volunteers! The Joomla! Automated Testing Working Group is looking for new members, which want to make Joomla! better https://volunteers.joomla.org/teams/automated-tests-working-group
  • 57. Questions? Thank you for listening! @yveshoppe

Notes de l'éditeur

  1. Testing levels
  2. Isolated, mostly method
  3. Normally you should only have one assertion per test
  4. Update to PHPUnit 5 is troublesome Lot’s of tests only testing mock and co
  5. Update to PHPUnit 5 is troublesome Lot’s of tests only testing mock and co
  6. Isolated, mostly method
  7. Testing levels
  8. More on that topic right after this from Niels
  9. Isolated, mostly method
  10. 7% of the code base (not mentioning inline js) is in JavaScript
  11. Isolated, mostly method
  12. 7% of the code base (not mentioning inline js) is in JavaScript