SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Downloaden Sie, um offline zu lesen
(Unit-)Testing for Joomla
Because breaking stuff sucks.
David Jardin

Automated Testing Working Group
11 April 2015
Image: © Raimond Spekking / Wikimedia Commons
3.2.6
3.3.5
2.5.26
3.3.3
2.5.24
2.5.22 3.1.4
THEORY OF TESTING
01
Image: © Tadekptaku / Wikimedia Commons
A unit test is an automated piece of code that
invokes a unit of work in the system and then
checks a single assumption about the
behavior of that unit of work.
UNIT TEST
Image: © KMJ / Wikimedia Commons
System testing is testing conducted on a
complete, integrated system to evaluate the
system's compliance with its specified
requirements.
SYSTEM TEST
Image: © Evo Flash / Wikimedia Commons
Joomla’s unit testing setup
02
PHPUnit
phpunit.xml
(Unit-)Testing for Joomla David Jardin
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/unit/bootstrap.php" colors=„false">
<!-- These constants help setup environment configurations for running
optional tests.
<php>
<const name="JTEST_DATABASE_MYSQL_DSN"
value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
<const name="JTEST_DATABASE_MYSQLI_DSN"
value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
<const name="JTEST_DATABASE_PDO_MYSQL_DSN"
value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
<const name="JTEST_DATABASE_POSTGRESQL_DSN"
value="host=localhost;port=5432;dbname=joomla_ut;user=utuser;pass=ut1234" />
<const name="JTEST_DATABASE_SQLSRV_DSN"
value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" />
<const name="JTEST_HTTP_STUB" value="http://localhost/joomla-cms/
tests/unit/stubs/jhttp_stub.php" />
</php>
-->
phpunit.xml
(Unit-)Testing for Joomla David Jardin
<testsuites>
<testsuite name="libraries-cms">
<directory>tests/unit/suites/libraries/cms</directory>
</testsuite>
<testsuite name="libraries-platform">
<directory>tests/unit/suites/libraries/joomla</directory>
</testsuite>
<testsuite name="libraries-legacy">
<directory>tests/unit/suites/libraries/legacy</directory>
</testsuite>
<testsuite name="database">
<directory>tests/unit/suites/database</directory>
</testsuite>
<testsuite name="administrator">
<directory>tests/unit/suites/administrator</directory>
</testsuite>
<testsuite name="FinderIndexer">
<directory>tests/unit/suites/finderIndexer</directory>
</testsuite>
</testsuites>
phpunit.xml
(Unit-)Testing for Joomla David Jardin
<logging>
<log type="coverage-html" target="build/coverage" title="Joomla-CMS"/>
<log type="coverage-clover" target="build/logs/clover.xml" />
<log type="junit" target="build/logs/junit.xml" />
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">libraries/cms</directory>
<directory suffix=".php">libraries/joomla</directory>
<directory suffix=".php">libraries/legacy</directory>
<directory suffix=".php">administrator/components/com_finder/helpers/
indexer</directory>
<file>administrator/includes/helper.php</file>
<file>libraries/loader.php</file>
<file>libraries/platform.php</file>
</whitelist>
</filter>
Setting up your machine
03
03. Setting up your machine
Requirements:
local *AMP-Stack
memory_limit = 512M
php_sqlite
php_curl
PHPUnit:
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
phpunit --version
(Unit-)Testing for Joomla David Jardin
Running the unit test suite
04
04. Running the unit test suite
cd /path/to/joomla-git-clone
phpunit
(Unit-)Testing for Joomla David Jardin
How to write a test : best practices
05
05. How to write a test : best practices
<?php
class Foo
{
public function bar($string)
{
if (is_int($string))
{
return false;
}
$string = strtoupper($string);
return $string;
}
}
(Unit-)Testing for Joomla David Jardin
05. How to write a test : best practices
<?php
class FooTest extends TestCase
{
public function testBar()
{
$object = new foo();
$this->assertEquals('EXAMPLE', $object->bar('example'));
$this->assertEquals(false, $object->bar(4));
}
}
(Unit-)Testing for Joomla David Jardin
One assertion per test.
05. How to write a test : best practices
<?php
class FooTest extends TestCase
{
public function testBar1()
{
$object = new foo();
$this->assertEquals('EXAMPLE', $object->bar('example'));
}
public function testBar2()
{
$object = new foo();
$this->assertEquals(false, $object->bar(4));
}
}
(Unit-)Testing for Joomla David Jardin
Use meaningful names for test methods.
05. How to write a test : best practices
<?php
class FooTest extends TestCase
{
public function testStringIsConvertedToUppercase()
{
$object = new foo();
$this->assertEquals('EXAMPLE', $object->bar('example'));
}
public function testFalseIsReturnedWhenIntIsUsedAsArgument()
{
$object = new foo();
$this->assertEquals(false, $object->bar(4));
}
}
(Unit-)Testing for Joomla David Jardin
Use the most specific assertion possible.
05. How to write a test : best practices
<?php
class FooTest extends TestCase
{
public function testStringIsConvertedToUppercase()
{
$object = new foo();
// assertSame is type safe, so in this case only strings are accepted
$this->assertSame('EXAMPLE', $object->bar('example'));
}
public function testFalseIsReturnedWhenIntIsUsedAsArgument()
{
$object = new foo();
// reduced code
$this->assertFalse($object->bar(4));
}
}
(Unit-)Testing for Joomla David Jardin
Run your tests with --strict and —verbose.
Use Testdox.
Joomla’s system testing setup
06
06. Joomla’s system testing setup
(Unit-)Testing for Joomla David Jardin
PHPUnit
Selenium Client for PHP
Selenium Webdriver API
Browser
Setting up your machine
07
PHP
Selenium
PHPUnit
Browser
Plugin
Browser
07. Setting up your machine
(Unit-)Testing for Joomla David Jardin
07. Setting up your machine
git clone https://github.com/joomla-projects/joomla-systemtest-env.git
cd joomla-systemtest-env
docker build -t joomlasystest-env .
(Unit-)Testing for Joomla David Jardin
Running the system test suite
08
08. Running the system test suite
docker run -i -t
-e REPO=https://github.com/joomla/joomla-cms joomlasystest-env
-e BRANCH=stating
(Unit-)Testing for Joomla David Jardin
08. Running the system test suite
(Unit-)Testing for Joomla David Jardin
Automation of automated tests
09
09. Automation of automated tests
(Unit-)Testing for Joomla David Jardin
09. Automation of automated tests
(Unit-)Testing for Joomla David Jardin
Jenkins
Jenkins-Slave Jenkins-Slave Jenkins-Slave
- Install
- Article Manager
- Install
- Weblinks
- Install
- Users
- … - … - …
09. Automation of automated tests
(Unit-)Testing for Joomla David Jardin
Conclusion
10
(Unit-)Testing for Joomla David Jardin
(Unit-)Testing for Joomla David Jardin
Image: © https://www.flickr.com/photos/narro/
THANK YOU!
David Jardin
@snipersister
david.jardin@community.joomla.org

Weitere ähnliche Inhalte

Was ist angesagt?

Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit TestingMike Lively
 
Writing good unit test
Writing good unit testWriting good unit test
Writing good unit testLucy Lu
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontendHeiko Hardt
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification QuestionsSpringMockExams
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkHumberto Marchezi
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationPaul Blundell
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitMichelangelo van Dam
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummiesHarry Potter
 
Effective Readable unit testing with junit5
Effective Readable unit testing with junit5Effective Readable unit testing with junit5
Effective Readable unit testing with junit5Sajith Vijesekara
 

Was ist angesagt? (20)

Grails Spock Testing
Grails Spock TestingGrails Spock Testing
Grails Spock Testing
 
Spring hibernate jsf_primefaces_intergration
Spring hibernate jsf_primefaces_intergrationSpring hibernate jsf_primefaces_intergration
Spring hibernate jsf_primefaces_intergration
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
 
Unit testing
Unit testingUnit testing
Unit testing
 
Writing good unit test
Writing good unit testWriting good unit test
Writing good unit test
 
7.Spring DI_2
7.Spring DI_27.Spring DI_2
7.Spring DI_2
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontend
 
Spring Certification Questions
Spring Certification QuestionsSpring Certification Questions
Spring Certification Questions
 
Unit testing
Unit testingUnit testing
Unit testing
 
6.Spring DI_1
6.Spring DI_16.Spring DI_1
6.Spring DI_1
 
Phpunit testing
Phpunit testingPhpunit testing
Phpunit testing
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing Framework
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 
UPC Testing talk 2
UPC Testing talk 2UPC Testing talk 2
UPC Testing talk 2
 
Agile Swift
Agile SwiftAgile Swift
Agile Swift
 
Unit test
Unit testUnit test
Unit test
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
 
Tdd & unit test
Tdd & unit testTdd & unit test
Tdd & unit test
 
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
 
Effective Readable unit testing with junit5
Effective Readable unit testing with junit5Effective Readable unit testing with junit5
Effective Readable unit testing with junit5
 

Ähnlich wie (Unit )-Testing for Joomla

Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDDEric Hogue
 
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)
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2Yi-Huan Chan
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitJames Fuller
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnitvaruntaliyan
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Eric Hogue
 
Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Oliver Klee
 
Unlock The Mystery Of PHPUnit (Wave PHP 2018)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)Unlock The Mystery Of PHPUnit (Wave PHP 2018)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)ENDelt260
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnitMindfire Solutions
 
EPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur PurnamaEPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur PurnamaEnterprise PHP Center
 
Getting Started with Test-Driven Development at Midwest PHP 2021
Getting Started with Test-Driven Development at Midwest PHP 2021Getting Started with Test-Driven Development at Midwest PHP 2021
Getting Started with Test-Driven Development at Midwest PHP 2021Scott Keck-Warren
 
Unit Testing in PHP
Unit Testing in PHPUnit Testing in PHP
Unit Testing in PHPRadu Murzea
 
Test-driven Development for TYPO3
Test-driven Development for TYPO3Test-driven Development for TYPO3
Test-driven Development for TYPO3Oliver Klee
 
Php Unit With Zend Framework Zendcon09
Php Unit With Zend Framework   Zendcon09Php Unit With Zend Framework   Zendcon09
Php Unit With Zend Framework Zendcon09Michelangelo van Dam
 

Ähnlich wie (Unit )-Testing for Joomla (20)

Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDD
 
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
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Laravel Unit Testing
Laravel Unit TestingLaravel Unit Testing
Laravel Unit Testing
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
Php tests tips
Php tests tipsPhp tests tips
Php tests tips
 
Unit Testing using PHPUnit
Unit Testing using  PHPUnitUnit Testing using  PHPUnit
Unit Testing using PHPUnit
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)Test-driven development for TYPO3 (T3DD11)
Test-driven development for TYPO3 (T3DD11)
 
Unlock The Mystery Of PHPUnit (Wave PHP 2018)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)Unlock The Mystery Of PHPUnit (Wave PHP 2018)
Unlock The Mystery Of PHPUnit (Wave PHP 2018)
 
Test Driven Development with PHPUnit
Test Driven Development with PHPUnitTest Driven Development with PHPUnit
Test Driven Development with PHPUnit
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
EPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur PurnamaEPHPC Webinar Slides: Unit Testing by Arthur Purnama
EPHPC Webinar Slides: Unit Testing by Arthur Purnama
 
3 j unit
3 j unit3 j unit
3 j unit
 
Getting Started with Test-Driven Development at Midwest PHP 2021
Getting Started with Test-Driven Development at Midwest PHP 2021Getting Started with Test-Driven Development at Midwest PHP 2021
Getting Started with Test-Driven Development at Midwest PHP 2021
 
Unit Testing in PHP
Unit Testing in PHPUnit Testing in PHP
Unit Testing in PHP
 
Test-driven Development for TYPO3
Test-driven Development for TYPO3Test-driven Development for TYPO3
Test-driven Development for TYPO3
 
Test ng for testers
Test ng for testersTest ng for testers
Test ng for testers
 
Php Unit With Zend Framework Zendcon09
Php Unit With Zend Framework   Zendcon09Php Unit With Zend Framework   Zendcon09
Php Unit With Zend Framework Zendcon09
 

Mehr von David Jardin

Joomla! in der Profiliga - eine Bestpractice-Sammlung
Joomla! in der Profiliga - eine Bestpractice-SammlungJoomla! in der Profiliga - eine Bestpractice-Sammlung
Joomla! in der Profiliga - eine Bestpractice-SammlungDavid Jardin
 
10 Tricks für Entwickler
10 Tricks für Entwickler10 Tricks für Entwickler
10 Tricks für EntwicklerDavid Jardin
 
Migration joomla 1.5 : 2.5
Migration joomla 1.5 : 2.5Migration joomla 1.5 : 2.5
Migration joomla 1.5 : 2.5David Jardin
 
CMS-Garden 2013 - How we brought Joomla! to the CeBIT
CMS-Garden 2013 - How we brought Joomla! to the CeBITCMS-Garden 2013 - How we brought Joomla! to the CeBIT
CMS-Garden 2013 - How we brought Joomla! to the CeBITDavid Jardin
 
Joomla! Organisationsstruktur
Joomla! OrganisationsstrukturJoomla! Organisationsstruktur
Joomla! OrganisationsstrukturDavid Jardin
 
Joomla! Versionsstrategie
Joomla! VersionsstrategieJoomla! Versionsstrategie
Joomla! VersionsstrategieDavid Jardin
 
Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.
Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.
Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.David Jardin
 
Content Construction Kit's für Joomla
Content Construction Kit's für JoomlaContent Construction Kit's für Joomla
Content Construction Kit's für JoomlaDavid Jardin
 

Mehr von David Jardin (12)

Der CMS-Garden
Der CMS-GardenDer CMS-Garden
Der CMS-Garden
 
Joomla! in der Profiliga - eine Bestpractice-Sammlung
Joomla! in der Profiliga - eine Bestpractice-SammlungJoomla! in der Profiliga - eine Bestpractice-Sammlung
Joomla! in der Profiliga - eine Bestpractice-Sammlung
 
Der J&Beyond e.V.
Der J&Beyond e.V.Der J&Beyond e.V.
Der J&Beyond e.V.
 
CMS-Garden
CMS-GardenCMS-Garden
CMS-Garden
 
10 Tricks für Entwickler
10 Tricks für Entwickler10 Tricks für Entwickler
10 Tricks für Entwickler
 
Migration joomla 1.5 : 2.5
Migration joomla 1.5 : 2.5Migration joomla 1.5 : 2.5
Migration joomla 1.5 : 2.5
 
CMS-Garden 2013 - How we brought Joomla! to the CeBIT
CMS-Garden 2013 - How we brought Joomla! to the CeBITCMS-Garden 2013 - How we brought Joomla! to the CeBIT
CMS-Garden 2013 - How we brought Joomla! to the CeBIT
 
Joomla! Organisationsstruktur
Joomla! OrganisationsstrukturJoomla! Organisationsstruktur
Joomla! Organisationsstruktur
 
SEBLOD CCK
SEBLOD CCKSEBLOD CCK
SEBLOD CCK
 
Joomla! Versionsstrategie
Joomla! VersionsstrategieJoomla! Versionsstrategie
Joomla! Versionsstrategie
 
Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.
Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.
Nooku, Molajo & Co - Joomla! Distributionen. Oder Forks.
 
Content Construction Kit's für Joomla
Content Construction Kit's für JoomlaContent Construction Kit's für Joomla
Content Construction Kit's für Joomla
 

Kürzlich hochgeladen

Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceEscorts Call Girls
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...nilamkumrai
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableSeo
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...nirzagarg
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubaikojalkojal131
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...SUHANI PANDEY
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 

Kürzlich hochgeladen (20)

Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
( Pune ) VIP Pimpri Chinchwad Call Girls 🎗️ 9352988975 Sizzling | Escorts | G...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 

(Unit )-Testing for Joomla

  • 1. (Unit-)Testing for Joomla Because breaking stuff sucks. David Jardin
 Automated Testing Working Group 11 April 2015
  • 2. Image: © Raimond Spekking / Wikimedia Commons
  • 3.
  • 4.
  • 6.
  • 8. Image: © Tadekptaku / Wikimedia Commons
  • 9. A unit test is an automated piece of code that invokes a unit of work in the system and then checks a single assumption about the behavior of that unit of work. UNIT TEST
  • 10. Image: © KMJ / Wikimedia Commons
  • 11. System testing is testing conducted on a complete, integrated system to evaluate the system's compliance with its specified requirements. SYSTEM TEST
  • 12. Image: © Evo Flash / Wikimedia Commons
  • 15.
  • 16.
  • 17. phpunit.xml (Unit-)Testing for Joomla David Jardin <?xml version="1.0" encoding="UTF-8"?> <phpunit bootstrap="tests/unit/bootstrap.php" colors=„false"> <!-- These constants help setup environment configurations for running optional tests. <php> <const name="JTEST_DATABASE_MYSQL_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" /> <const name="JTEST_DATABASE_MYSQLI_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" /> <const name="JTEST_DATABASE_PDO_MYSQL_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" /> <const name="JTEST_DATABASE_POSTGRESQL_DSN" value="host=localhost;port=5432;dbname=joomla_ut;user=utuser;pass=ut1234" /> <const name="JTEST_DATABASE_SQLSRV_DSN" value="host=localhost;dbname=joomla_ut;user=utuser;pass=ut1234" /> <const name="JTEST_HTTP_STUB" value="http://localhost/joomla-cms/ tests/unit/stubs/jhttp_stub.php" /> </php> -->
  • 18. phpunit.xml (Unit-)Testing for Joomla David Jardin <testsuites> <testsuite name="libraries-cms"> <directory>tests/unit/suites/libraries/cms</directory> </testsuite> <testsuite name="libraries-platform"> <directory>tests/unit/suites/libraries/joomla</directory> </testsuite> <testsuite name="libraries-legacy"> <directory>tests/unit/suites/libraries/legacy</directory> </testsuite> <testsuite name="database"> <directory>tests/unit/suites/database</directory> </testsuite> <testsuite name="administrator"> <directory>tests/unit/suites/administrator</directory> </testsuite> <testsuite name="FinderIndexer"> <directory>tests/unit/suites/finderIndexer</directory> </testsuite> </testsuites>
  • 19. phpunit.xml (Unit-)Testing for Joomla David Jardin <logging> <log type="coverage-html" target="build/coverage" title="Joomla-CMS"/> <log type="coverage-clover" target="build/logs/clover.xml" /> <log type="junit" target="build/logs/junit.xml" /> </logging> <filter> <whitelist addUncoveredFilesFromWhitelist="true"> <directory suffix=".php">libraries/cms</directory> <directory suffix=".php">libraries/joomla</directory> <directory suffix=".php">libraries/legacy</directory> <directory suffix=".php">administrator/components/com_finder/helpers/ indexer</directory> <file>administrator/includes/helper.php</file> <file>libraries/loader.php</file> <file>libraries/platform.php</file> </whitelist> </filter>
  • 20.
  • 21. Setting up your machine 03
  • 22. 03. Setting up your machine Requirements: local *AMP-Stack memory_limit = 512M php_sqlite php_curl PHPUnit: wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar sudo mv phpunit.phar /usr/local/bin/phpunit phpunit --version (Unit-)Testing for Joomla David Jardin
  • 23. Running the unit test suite 04
  • 24. 04. Running the unit test suite cd /path/to/joomla-git-clone phpunit (Unit-)Testing for Joomla David Jardin
  • 25.
  • 26. How to write a test : best practices 05
  • 27. 05. How to write a test : best practices <?php class Foo { public function bar($string) { if (is_int($string)) { return false; } $string = strtoupper($string); return $string; } } (Unit-)Testing for Joomla David Jardin
  • 28. 05. How to write a test : best practices <?php class FooTest extends TestCase { public function testBar() { $object = new foo(); $this->assertEquals('EXAMPLE', $object->bar('example')); $this->assertEquals(false, $object->bar(4)); } } (Unit-)Testing for Joomla David Jardin
  • 30. 05. How to write a test : best practices <?php class FooTest extends TestCase { public function testBar1() { $object = new foo(); $this->assertEquals('EXAMPLE', $object->bar('example')); } public function testBar2() { $object = new foo(); $this->assertEquals(false, $object->bar(4)); } } (Unit-)Testing for Joomla David Jardin
  • 31. Use meaningful names for test methods.
  • 32. 05. How to write a test : best practices <?php class FooTest extends TestCase { public function testStringIsConvertedToUppercase() { $object = new foo(); $this->assertEquals('EXAMPLE', $object->bar('example')); } public function testFalseIsReturnedWhenIntIsUsedAsArgument() { $object = new foo(); $this->assertEquals(false, $object->bar(4)); } } (Unit-)Testing for Joomla David Jardin
  • 33. Use the most specific assertion possible.
  • 34. 05. How to write a test : best practices <?php class FooTest extends TestCase { public function testStringIsConvertedToUppercase() { $object = new foo(); // assertSame is type safe, so in this case only strings are accepted $this->assertSame('EXAMPLE', $object->bar('example')); } public function testFalseIsReturnedWhenIntIsUsedAsArgument() { $object = new foo(); // reduced code $this->assertFalse($object->bar(4)); } } (Unit-)Testing for Joomla David Jardin
  • 35. Run your tests with --strict and —verbose.
  • 37.
  • 39. 06. Joomla’s system testing setup (Unit-)Testing for Joomla David Jardin PHPUnit Selenium Client for PHP Selenium Webdriver API Browser
  • 40.
  • 41. Setting up your machine 07
  • 43. 07. Setting up your machine (Unit-)Testing for Joomla David Jardin
  • 44. 07. Setting up your machine git clone https://github.com/joomla-projects/joomla-systemtest-env.git cd joomla-systemtest-env docker build -t joomlasystest-env . (Unit-)Testing for Joomla David Jardin
  • 45. Running the system test suite 08
  • 46. 08. Running the system test suite docker run -i -t -e REPO=https://github.com/joomla/joomla-cms joomlasystest-env -e BRANCH=stating (Unit-)Testing for Joomla David Jardin
  • 47. 08. Running the system test suite (Unit-)Testing for Joomla David Jardin
  • 49.
  • 50. 09. Automation of automated tests (Unit-)Testing for Joomla David Jardin
  • 51. 09. Automation of automated tests (Unit-)Testing for Joomla David Jardin Jenkins Jenkins-Slave Jenkins-Slave Jenkins-Slave - Install - Article Manager - Install - Weblinks - Install - Users - … - … - …
  • 52. 09. Automation of automated tests (Unit-)Testing for Joomla David Jardin
  • 53.