SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Preparing for
        PHP TestFest 2009


by Felix De Vliegher and Michelangelo van Dam
Welcome to PHP Test Fest 2009 !
• What is PHP Test Fest ?
 – improving code coverage of the PHP interpreter by
   writing tests
 – opportunity to learn how to write tests in a group/
   workshop like environment
 – your chance to contribute back to the PHP
   community !




                                                         2
Prerequisites
• preferable a Linux version
  – virtual machine
  – core OS
• with gcc and gcov (see next slide for details)
• for testing coverages
  – gcov
  – lcov (version 1.5 or 1.6)
• php 5.3
  – from CVS (see next slide)
• text editor like vi(m), textpad, pico, ...


                                                   3
Tools needed for PHP builds
• gcc: 3.4+ (with gcov)
Source: http://wiki.php.net/doc/articles/writing-tests


•   autoconf: 2.13
•   automake: 1.4+
•   libtool: 1.4.x+ (except 1.4.2)
•   bison: 1.28, 1.35, 1.75, 2.0 or higher
•   flex: 2.5.4 (not higher)
•   re2c: 0.9.11+ (0.12.0+ for HEAD)
Source: http://www.php.net/anoncvs.php




                                                         4
Getting lcov
• apt
 – apt-get install lcov
• CSV
 – cvs -
   d:pserver:anonymous@ltp.cvs.sourceforge.net:/
   cvsroot/ltp login
 – cvs -z3 -
   d:pserver:anonymous@ltp.cvs.sourceforge.net:/
   cvsroot/ltp co -r LCOV_1_6 -P utils/analysis/lcov
• RPM
 – lcov-1.6-2.noarch.rpm



                                                       5
Getting the latest PHP 5.3
Choose a development environment
$   cd ~/src/php/
$   cvs -d :pserver:cvsread@cvs.php.net:/repository checkout -
r   PHP_5_3 php5
$   cd php5


Build a configure for your current version
$ ./buildconf

Run the configuration
$ ./configure --enable-gcov
choose --enable-gcov for code coverage reporting

make & make test & make lcov
$ make
$ make test
$ make lcov TESTS=tests/*




                                                                 6
Code coverage report




http://gcov.php.net or in your /path/to/php5/lcov_html directory




                                                                   7
Writing Tests
• What are phpt Tests ?
  Files ending with .phpt are test files
  containing a single test
• What skills do I need to write phpt tests ?
  – basic knowledge of PHP
  – a text editor like vi(m), pico, notepad, textpad, ...
  – a way to get results of your test code
• Where can I find more info about phpt ?
  http://phpt.info




                                                            8
Naming conventions
• Tests for bugs
  – bug<bugid>.phpt (bug17123.phpt)
• Tests for a function’s basic behaviour
  – <functionname>_basic.phpt (dba_open_basic.phpt)
• Tests for a function’s error behaviour
  – <functionname>_error.phpt (dba_open_error.phpt)
• Tests for variations in a function’s behaviour
  – <functionname>_variation.phpt (dba_open_variation.phpt)
• General tests for extensions
  – <extname>_<no>.phpt (dba_003.phpt)



                                                              9
Basic format
--TEST--
Hello World
--FILE--
Hello World
--EXPECT--
Hello World




                             10
Test, File and Expect
--TEST--
Hello World
--FILE--
<?php echo ‘Hello World’; ?>
--EXPECT--
Hello World




                                    11
Testing Errors
--TEST--
Hello World
--FILE--
<?php echo ‘Hello World
--EXPECTF--
Parse Error: syntax error, unexpected $end in %s.php on line
%d




                                                               12
Testing Errors with expectregex
--TEST--
Hello World
--FILE--
<?php echo ‘Hello World
--EXPECTREGEX--
Parse Error: (parse|syntax) error, unexpected $end in .*
ON .*




                                                           13
Cleaning up
--TEST--
This will remove temporary files
--FILE--
<?php
$temp_filename = dirname(__FILE__) . '/foo.tmp';
$fp = fopen($temp_filename, 'w');
fwrite($fp, 'bar');
fclose($fp);
?>
--CLEAN--
<?php
$temp_filename = dirname(__FILE__) . '/foo.tmp';
unlink($temp_filename);
?>
--EXPECT--




                                                   14
Conditional Testing
--TEST--
Check for 64bit platform
--SKIPIF--
<?php
if (PHP_INT_SIZE != 8) die('64bit platforms only');
?>
--FILE--
--EXPECT--




                                                      15
Don’t forget the credits
--TEST--
A test with a CREDITS section
--CREDITS--
John Doe <john.doe@example.com>
#testfest PHPBelgium 2009-05-09
--FILE--
--EXPECT--




                                     16
Running your test




make test TESTS=/path/to/php5/ext/yourextension/tests




                                                        17
Resources
• TestFest
  http://qa.php.net/testfest.php
• PHP Quality Assurance Team
  http://qa.php.net/
• PHP: Test and Code Coverage Analysis
  http://gcov.php.net/
• Complete ./configure example
  http://gcov.php.net/viewer.php?
  version=PHP_5_3&func=system




                                         18
Let PHP Test Fest begin !


    Thank you for your interest !
  Your work will be appreciated !!!

        Slides are available on
http://www.slideshare.net/PHPBelgium




                                       19
Proudly sponsored




                    20

Weitere ähnliche Inhalte

Was ist angesagt?

Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Andrea Francia
 
Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTestRaihan Masud
 
Nagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton VoonNagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton VoonNETWAYS
 
Getting started with PHPUnit
Getting started with PHPUnitGetting started with PHPUnit
Getting started with PHPUnitKhyati Gala
 
Trust, but verify | Testing with Docker Containers
Trust, but verify | Testing with Docker ContainersTrust, but verify | Testing with Docker Containers
Trust, but verify | Testing with Docker ContainersNan Liu
 
Cell processor lab
Cell processor labCell processor lab
Cell processor labcoolmirza143
 
Who’s afraid of WinDbg
Who’s afraid of WinDbgWho’s afraid of WinDbg
Who’s afraid of WinDbgDror Helper
 
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdbPython Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdbP3 InfoTech Solutions Pvt. Ltd.
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxDamien Seguy
 
PHPVigo #26 - Lightning Docker phpUnit
PHPVigo #26 - Lightning Docker phpUnitPHPVigo #26 - Lightning Docker phpUnit
PHPVigo #26 - Lightning Docker phpUnitRolando Caldas
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneDavid Glick
 
Linux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioLinux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioPVS-Studio
 
Unit testing symfony plugins with php unit
Unit testing symfony plugins with php unitUnit testing symfony plugins with php unit
Unit testing symfony plugins with php unitChristian Schaefer
 

Was ist angesagt? (20)

skipfish
skipfishskipfish
skipfish
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008
 
Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTest
 
Nagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton VoonNagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton Voon
 
Getting started with PHPUnit
Getting started with PHPUnitGetting started with PHPUnit
Getting started with PHPUnit
 
Trust, but verify | Testing with Docker Containers
Trust, but verify | Testing with Docker ContainersTrust, but verify | Testing with Docker Containers
Trust, but verify | Testing with Docker Containers
 
Cell processor lab
Cell processor labCell processor lab
Cell processor lab
 
Gcc opt
Gcc optGcc opt
Gcc opt
 
Who’s afraid of WinDbg
Who’s afraid of WinDbgWho’s afraid of WinDbg
Who’s afraid of WinDbg
 
Zend Framework 2 - PHPUnit
Zend Framework 2 - PHPUnitZend Framework 2 - PHPUnit
Zend Framework 2 - PHPUnit
 
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdbPython Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdb
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Os Cook
Os CookOs Cook
Os Cook
 
Php 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php beneluxPhp 7.2 compliance workshop php benelux
Php 7.2 compliance workshop php benelux
 
Makefiles Bioinfo
Makefiles BioinfoMakefiles Bioinfo
Makefiles Bioinfo
 
PHPVigo #26 - Lightning Docker phpUnit
PHPVigo #26 - Lightning Docker phpUnitPHPVigo #26 - Lightning Docker phpUnit
PHPVigo #26 - Lightning Docker phpUnit
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
Linux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioLinux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-Studio
 
Unit testing symfony plugins with php unit
Unit testing symfony plugins with php unitUnit testing symfony plugins with php unit
Unit testing symfony plugins with php unit
 
Adpatch options
Adpatch optionsAdpatch options
Adpatch options
 

Ähnlich wie Prepare for PHP Test Fest 2009

第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会Ippei Ogiwara
 
CLI, the other SAPI
CLI, the other SAPICLI, the other SAPI
CLI, the other SAPICombell NV
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6Wim Godden
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesAutomatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesOtto Kekäläinen
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Jeff Jones
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confooCombell NV
 
PHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentationPHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentationLorna Mitchell
 
php & performance
 php & performance php & performance
php & performancesimon8410
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance毅 吕
 
DevOps in PHP environment
DevOps in PHP environment DevOps in PHP environment
DevOps in PHP environment Evaldo Felipe
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Combell NV
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hosterCombell NV
 
Tips
TipsTips
Tipsmclee
 

Ähnlich wie Prepare for PHP Test Fest 2009 (20)

第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
 
CLI, the other SAPI
CLI, the other SAPICLI, the other SAPI
CLI, the other SAPI
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Api Design
Api DesignApi Design
Api Design
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themesAutomatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themes
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
Php through the eyes of a hoster confoo
Php through the eyes of a hoster confooPhp through the eyes of a hoster confoo
Php through the eyes of a hoster confoo
 
PHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentationPHPNW Test Fest Pre-presentation
PHPNW Test Fest Pre-presentation
 
php & performance
 php & performance php & performance
php & performance
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
DevOps in PHP environment
DevOps in PHP environment DevOps in PHP environment
DevOps in PHP environment
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
 
Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11Php through the eyes of a hoster phpbnl11
Php through the eyes of a hoster phpbnl11
 
What's new with PHP7
What's new with PHP7What's new with PHP7
What's new with PHP7
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 
Test
TestTest
Test
 
Php through the eyes of a hoster
Php through the eyes of a hosterPhp through the eyes of a hoster
Php through the eyes of a hoster
 
Tips
TipsTips
Tips
 

Kürzlich hochgeladen

March 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterMarch 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterssuserdfec6a
 
What are some effective methods for increasing concentration and focus while ...
What are some effective methods for increasing concentration and focus while ...What are some effective methods for increasing concentration and focus while ...
What are some effective methods for increasing concentration and focus while ...SOFTTECHHUB
 
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsHisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDeepika Singh
 
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...aarushi sharma
 
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsGoregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDeepika Singh
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607dollysharma2066
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...mitaliverma221
 
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdfExploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdfMindful Wellness Journey
 
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxSIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxStephenMino
 
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsColaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDeepika Singh
 
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime BokaroBokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaromeghakumariji156
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterssuserdfec6a
 
Emotional Freedom Technique Tapping Points Diagram.pdf
Emotional Freedom Technique Tapping Points Diagram.pdfEmotional Freedom Technique Tapping Points Diagram.pdf
Emotional Freedom Technique Tapping Points Diagram.pdfaprilross605
 
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDeepika Singh
 
Social Learning Theory presentation.pptx
Social Learning Theory presentation.pptxSocial Learning Theory presentation.pptx
Social Learning Theory presentation.pptxumef01177
 
2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing YogaRaphaël Semeteys
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...Cara Menggugurkan Kandungan 087776558899
 

Kürzlich hochgeladen (18)

March 2023 Recommendations for newsletter
March 2023 Recommendations for newsletterMarch 2023 Recommendations for newsletter
March 2023 Recommendations for newsletter
 
What are some effective methods for increasing concentration and focus while ...
What are some effective methods for increasing concentration and focus while ...What are some effective methods for increasing concentration and focus while ...
What are some effective methods for increasing concentration and focus while ...
 
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsHisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Hisar Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
(JAYA)🎄Low Rate Call Girls Lucknow Call Now 8630512678 Premium Collection Of ...
 
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsGoregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Goregaon West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377087607
 
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
Call Girls In Mumbai Just Genuine Call ☎ 7738596112✅ Call Girl Andheri East G...
 
Girls in Mahipalpur (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Mahipalpur  (delhi) call me [🔝9953056974🔝] escort service 24X7Girls in Mahipalpur  (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Mahipalpur (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdfExploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
Exploring Stoic Philosophy From Ancient Wisdom to Modern Relevance.pdf
 
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptxSIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
SIKP311 Sikolohiyang Pilipino - Ginhawa.pptx
 
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsColaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Colaba Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime BokaroBokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
Bokaro Escorts Service Girl ^ 9332606886, WhatsApp Anytime Bokaro
 
February 2024 Recommendations for newsletter
February 2024 Recommendations for newsletterFebruary 2024 Recommendations for newsletter
February 2024 Recommendations for newsletter
 
Emotional Freedom Technique Tapping Points Diagram.pdf
Emotional Freedom Technique Tapping Points Diagram.pdfEmotional Freedom Technique Tapping Points Diagram.pdf
Emotional Freedom Technique Tapping Points Diagram.pdf
 
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot GirlsDadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
Dadar West Escorts 🥰 8617370543 Call Girls Offer VIP Hot Girls
 
Social Learning Theory presentation.pptx
Social Learning Theory presentation.pptxSocial Learning Theory presentation.pptx
Social Learning Theory presentation.pptx
 
2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga2023 - Between Philosophy and Practice: Introducing Yoga
2023 - Between Philosophy and Practice: Introducing Yoga
 
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
KLINIK BATA Jual obat penggugur kandungan 087776558899 ABORSI JANIN KEHAMILAN...
 

Prepare for PHP Test Fest 2009

  • 1. Preparing for PHP TestFest 2009 by Felix De Vliegher and Michelangelo van Dam
  • 2. Welcome to PHP Test Fest 2009 ! • What is PHP Test Fest ? – improving code coverage of the PHP interpreter by writing tests – opportunity to learn how to write tests in a group/ workshop like environment – your chance to contribute back to the PHP community ! 2
  • 3. Prerequisites • preferable a Linux version – virtual machine – core OS • with gcc and gcov (see next slide for details) • for testing coverages – gcov – lcov (version 1.5 or 1.6) • php 5.3 – from CVS (see next slide) • text editor like vi(m), textpad, pico, ... 3
  • 4. Tools needed for PHP builds • gcc: 3.4+ (with gcov) Source: http://wiki.php.net/doc/articles/writing-tests • autoconf: 2.13 • automake: 1.4+ • libtool: 1.4.x+ (except 1.4.2) • bison: 1.28, 1.35, 1.75, 2.0 or higher • flex: 2.5.4 (not higher) • re2c: 0.9.11+ (0.12.0+ for HEAD) Source: http://www.php.net/anoncvs.php 4
  • 5. Getting lcov • apt – apt-get install lcov • CSV – cvs - d:pserver:anonymous@ltp.cvs.sourceforge.net:/ cvsroot/ltp login – cvs -z3 - d:pserver:anonymous@ltp.cvs.sourceforge.net:/ cvsroot/ltp co -r LCOV_1_6 -P utils/analysis/lcov • RPM – lcov-1.6-2.noarch.rpm 5
  • 6. Getting the latest PHP 5.3 Choose a development environment $ cd ~/src/php/ $ cvs -d :pserver:cvsread@cvs.php.net:/repository checkout - r PHP_5_3 php5 $ cd php5 Build a configure for your current version $ ./buildconf Run the configuration $ ./configure --enable-gcov choose --enable-gcov for code coverage reporting make & make test & make lcov $ make $ make test $ make lcov TESTS=tests/* 6
  • 7. Code coverage report http://gcov.php.net or in your /path/to/php5/lcov_html directory 7
  • 8. Writing Tests • What are phpt Tests ? Files ending with .phpt are test files containing a single test • What skills do I need to write phpt tests ? – basic knowledge of PHP – a text editor like vi(m), pico, notepad, textpad, ... – a way to get results of your test code • Where can I find more info about phpt ? http://phpt.info 8
  • 9. Naming conventions • Tests for bugs – bug<bugid>.phpt (bug17123.phpt) • Tests for a function’s basic behaviour – <functionname>_basic.phpt (dba_open_basic.phpt) • Tests for a function’s error behaviour – <functionname>_error.phpt (dba_open_error.phpt) • Tests for variations in a function’s behaviour – <functionname>_variation.phpt (dba_open_variation.phpt) • General tests for extensions – <extname>_<no>.phpt (dba_003.phpt) 9
  • 10. Basic format --TEST-- Hello World --FILE-- Hello World --EXPECT-- Hello World 10
  • 11. Test, File and Expect --TEST-- Hello World --FILE-- <?php echo ‘Hello World’; ?> --EXPECT-- Hello World 11
  • 12. Testing Errors --TEST-- Hello World --FILE-- <?php echo ‘Hello World --EXPECTF-- Parse Error: syntax error, unexpected $end in %s.php on line %d 12
  • 13. Testing Errors with expectregex --TEST-- Hello World --FILE-- <?php echo ‘Hello World --EXPECTREGEX-- Parse Error: (parse|syntax) error, unexpected $end in .* ON .* 13
  • 14. Cleaning up --TEST-- This will remove temporary files --FILE-- <?php $temp_filename = dirname(__FILE__) . '/foo.tmp'; $fp = fopen($temp_filename, 'w'); fwrite($fp, 'bar'); fclose($fp); ?> --CLEAN-- <?php $temp_filename = dirname(__FILE__) . '/foo.tmp'; unlink($temp_filename); ?> --EXPECT-- 14
  • 15. Conditional Testing --TEST-- Check for 64bit platform --SKIPIF-- <?php if (PHP_INT_SIZE != 8) die('64bit platforms only'); ?> --FILE-- --EXPECT-- 15
  • 16. Don’t forget the credits --TEST-- A test with a CREDITS section --CREDITS-- John Doe <john.doe@example.com> #testfest PHPBelgium 2009-05-09 --FILE-- --EXPECT-- 16
  • 17. Running your test make test TESTS=/path/to/php5/ext/yourextension/tests 17
  • 18. Resources • TestFest http://qa.php.net/testfest.php • PHP Quality Assurance Team http://qa.php.net/ • PHP: Test and Code Coverage Analysis http://gcov.php.net/ • Complete ./configure example http://gcov.php.net/viewer.php? version=PHP_5_3&func=system 18
  • 19. Let PHP Test Fest begin ! Thank you for your interest ! Your work will be appreciated !!! Slides are available on http://www.slideshare.net/PHPBelgium 19

Hinweis der Redaktion