Slideshare.net (beta)

 
Post: 
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons



All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 0 (more)

PHP TestFest - Cologne

From sebastian_bergmann, 2 months ago

1302 views  |  0 comments  |  0 favorites  |  36 downloads  |  14 embeds (Stats)
 
 
 

Groups/Events

Not added to any group/event

 
 

Privacy InfoNew!

This slideshow is Public

 
CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License
Embed in your blog
Embed (wordpress.com)
custom

Slideshow transcript

Slide 1: Welcome to TestFest! Cologne – May 2nd 2008

Slide 2: Welcome to TestFest! If this is your first fest, you have to test! What is this about? – Event that aims at improving the code coverage of the PHP interpreter itself by writing tests. – The point is that people, such as a user group, network to learn together. – Great opportunity to contribute back to the PHP project.

Slide 3: PHPT Tests ● Single test in a single .phpt file ● Each test is run in a separate PHP process – Complete test isolation – PHP configuration can be changed per test – Test Suite survives fatal errors, segfaults, ... ● Original implementation: run-tests.php ● PEAR_RunTest – Used by PHPUnit_Extensions_PhptTestCase ● PHPT (http://phpt.info/)

Slide 4: Writing PHPT Tests Naming Conventions ● Tests for bugs – bug<bugid>.phpt ● Tests for a function's basic behaviour – <functionname>_basic.phpt ● Tests for a function's error behaviour – <functionname>_error.phpt ● Tests for variations in a function's behaviour – <functionname>_variation.phpt ● General tests for extensions – <extname><no>.phpt

Slide 5: Writing PHPT Tests TEST, FILE, and EXPECT --TEST-- Hello World --FILE-- Hello World --EXPECT-- Hello World

Slide 6: Writing PHPT Tests TEST, FILE, and EXPECT --TEST-- Hello World --FILE-- <?php print 'Hello World'; ?> --EXPECT-- Hello World

Slide 7: Writing PHPT Tests EXPECTF --TEST-- Hello World --FILE-- <?php print 'Hello World --EXPECTF-- Parse error: syntax error, unexpected $end in %s.php on line %d ● %s any string ● %i integers ● %d numbers ● %f floats ● %c single character ● %x hexadecimal ● %w whitespace ● %e directory sep.

Slide 8: Writing PHPT Tests EXPECTREGEX --TEST-- Hello World --FILE-- <?php print 'Hello World --EXPECTREGEX-- Parse error: (parse|syntax) error, unexpected $end in .* on .*

Slide 9: Writing PHPT Tests CLEAN --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--

Slide 10: Writing PHPT Tests Writing portable tests --TEST-- Test uses a hard-defined timezone --INI-- date.timezone=UTC --FILE-- --EXPECT--

Slide 11: Writing PHPT Tests Writing portable tests --TEST-- Check for 32bit platform --SKIPIF-- <?php if (PHP_INT_SIZE != 4) die('32bit platforms only'); ?> --FILE-- --EXPECT--

Slide 12: Writing PHPT Tests Writing portable tests --TEST-- Check for 64bit platform --SKIPIF-- <?php if (PHP_INT_SIZE != 8) die('64bit platforms only'); ?> --FILE-- --EXPECT--

Slide 13: Writing PHPT Tests Writing portable tests --TEST-- Check for Linux platform --SKIPIF-- <?php if (!stristr(PHP_OS, 'Linux')) die('Linux only'); ?> --FILE-- --EXPECT--

Slide 14: Writing PHPT Tests Writing portable tests --TEST-- Check for MacOS X platform --SKIPIF-- <?php if (!stristr(PHP_OS, 'Darwin')) die('MacOS X only'); ?> --FILE-- --EXPECT--

Slide 15: Writing PHPT Tests Writing portable tests --TEST-- Check for Windows platform --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) != 'WIN') die('Windows only'); ?> --FILE-- --EXPECT--

Slide 16: Writing PHPT Tests CREDITS --TEST-- A test with a CREDITS section --CREDITS-- Joe Testwriter <joe@foo.bar> #testfest cologne on 2008-05-02 --FILE-- --EXPECT--

Slide 17: Running PHP's Test Suite sb@ubuntu php-5.3 % ./configure && make && make test . . . TEST RESULT SUMMARY --------------------------------------------------------------------- Exts skipped : 47 Exts tested : 34 --------------------------------------------------------------------- Number of tests : 6518 4786 Tests skipped : 1732 ( 26.6%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 13 ( 0.2%) ( 0.3%) Tests passed : 4773 ( 73.2%) ( 99.7%) --------------------------------------------------------------------- Time taken : 423 seconds sb@ubuntu php-5.3 % ./configure --enable-gcov && make && make lcov . . . Overall coverage rate: 82665 of 148813 lines (55.5%)

Slide 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/

Slide 19: The End ● Thank you for your interest! ● These slides will be available shortly on http://sebastian-bergmann.de/talks/.

Slide 20: License   This presentation material is published under the Attribution-Share Alike 3.0 Unported license.   You are free: ✔ to Share – to copy, distribute and transmit the work. ✔ to Remix – to adapt the work.   Under the following conditions: ● Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). ● Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.   For any reuse or distribution, you must make clear to others the license terms of this work.   Any of the above conditions can be waived if you get permission from the copyright holder.   Nothing in this license impairs or restricts the author's moral rights.