0
TestFest 2009
   PHP Netherland, Utrecht
               Pierre Joye
 Thanks you for joining us!

 First tests fest?

First test (I won’t tell your boss)?




Welcome to the TestFest 2009!
 PHP needs YOU

 You need PHP too

a broken PHP is useless

A new Phpet is waiting for you!

What should I bother?
 Improve code coverage

 Fantastic opportunity to be part of PHP

 Network to learn and work together




What is this ...
 Single test in a single .phpt file

 Small set of similar tests in a .phpt file

 Each test are run by calling a new p...
 (n)make test

 make test
          
 TESTS=/home/joe/php/ext/reflection/tests
 make test
          
 TESTS=/home/joe/p...
 A bug
    bug12345.phpt (bug.php.net/12345)
 Features
    <functionname>_basic.phpt
 Errors
    <functionname>_erro...
--TEST—
Not testing PHP
--FILE—
Goede morgen
--EXPECT—
Goede morgen




Simplest test ever
--TEST—
Let try to test echo!
--FILE—
<?php echo “Hoe doet u?”; ?>
--EXPECT—
Ik heb nodig koffie




2nd most simplest tes...
--TEST—
rand
--FILE—
<?php echo “rand: ”. rand(); ?>
--EXPECT—
rand: %d




Expect using printf syntax
--TEST—
rand
--FILE—
<?php echo “rand: ”. rand(); ?>
--EXPECTREGEX—
M_E: 2.718281[0-9]*




Expect using regex syntax   (a...
http://qa.php.net/expectf_details.php




Where to find the EXPECTF
placeholders list
--TEST—
Timezone
--INI—
date.timezone=Europe/Berlin
--FILE—
<?php echo date_timezone_get(); ?>
--EXPECT—
Europe/Berlin



...
--TEST—
Timezone
--SKIPIF—
<?php if (! extension_loaded („myext‟)
  die(„myext not available‟); ?>
--FILE—
…
--EXPECT—
..
...
--TEST—
Timezone
--CREDITS—
John TheWriter
#testfest Utrecht 2009
--FILE—
…
--EXPECT—
..

Render unto Caesar the things
wh...
http://qa.php.net/phpt_details.php




Complete doc about phpt (with samples!)
Keep it smalll and beautiful

Test one feature per phpt

Avoid large output




What is a good test?
If a large output is necessary

Numerate or name each line

  Easier to analyze
  Easier to debug


What is a good tes...
PHP GCOV - Test and Code Coverage Analysis

    http://gcov.php.net/
    PHP WIKI - How to look at the test coverage for ...
Upcoming SlideShare
Loading in...5
×

Test Fest 2009

1,572

Published on

Presentation PHP Testfest 2009 Utrecht.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,572
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Test Fest 2009"

  1. 1. TestFest 2009 PHP Netherland, Utrecht Pierre Joye
  2. 2.  Thanks you for joining us!  First tests fest? First test (I won’t tell your boss)? Welcome to the TestFest 2009!
  3. 3.  PHP needs YOU  You need PHP too a broken PHP is useless A new Phpet is waiting for you! What should I bother?
  4. 4.  Improve code coverage  Fantastic opportunity to be part of PHP  Network to learn and work together What is this about?
  5. 5.  Single test in a single .phpt file  Small set of similar tests in a .phpt file  Each test are run by calling a new php instance  Test isolation  Custom configuration  Support of segfaults and other fatal errors PHPT
  6. 6.  (n)make test  make test TESTS=/home/joe/php/ext/reflection/tests  make test TESTS=/home/joe/php/ext/a/tests/b.phpt Testing PHP, everything (or less)
  7. 7.  A bug  bug12345.phpt (bug.php.net/12345)  Features  <functionname>_basic.phpt  Errors  <functionname>_error.phpt  General  extname<test nr>.phpt Naming convention
  8. 8. --TEST— Not testing PHP --FILE— Goede morgen --EXPECT— Goede morgen Simplest test ever
  9. 9. --TEST— Let try to test echo! --FILE— <?php echo “Hoe doet u?”; ?> --EXPECT— Ik heb nodig koffie 2nd most simplest test ever (failing)
  10. 10. --TEST— rand --FILE— <?php echo “rand: ”. rand(); ?> --EXPECT— rand: %d Expect using printf syntax
  11. 11. --TEST— rand --FILE— <?php echo “rand: ”. rand(); ?> --EXPECTREGEX— M_E: 2.718281[0-9]* Expect using regex syntax (avoid it)
  12. 12. http://qa.php.net/expectf_details.php Where to find the EXPECTF placeholders list
  13. 13. --TEST— Timezone --INI— date.timezone=Europe/Berlin --FILE— <?php echo date_timezone_get(); ?> --EXPECT— Europe/Berlin Custom ini settings
  14. 14. --TEST— Timezone --SKIPIF— <?php if (! extension_loaded („myext‟) die(„myext not available‟); ?> --FILE— … --EXPECT— .. Conditional test
  15. 15. --TEST— Timezone --CREDITS— John TheWriter #testfest Utrecht 2009 --FILE— … --EXPECT— .. Render unto Caesar the things which are Caesar’s
  16. 16. http://qa.php.net/phpt_details.php Complete doc about phpt (with samples!)
  17. 17. Keep it smalll and beautiful Test one feature per phpt Avoid large output What is a good test?
  18. 18. If a large output is necessary Numerate or name each line Easier to analyze Easier to debug What is a good test?
  19. 19. PHP GCOV - Test and Code Coverage Analysis  http://gcov.php.net/ PHP WIKI - How to look at the test coverage for an extension  http://wiki.php.net/qa/testcoverage PHP QA - Writing Tests  http://qa.php.net/write-test.php Lessons Learned from PHPT  Writinghttp://wiki.php.net/qa/phptlessonslearned PHP CVS - README.TESTING  http://cvs.php.net/viewvc.cgi/php-src/README.TESTING Resources
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×