Your SlideShare is downloading. ×

Test Fest 2009

1,538

Published on

Presentation PHP Testfest 2009 Utrecht.

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,538
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. TestFest 2009 PHP Netherland, Utrecht Pierre Joye
  • 2.  Thanks you for joining us!  First tests fest? First test (I won’t tell your boss)? Welcome to the TestFest 2009!
  • 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.  Improve code coverage  Fantastic opportunity to be part of PHP  Network to learn and work together What is this about?
  • 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.  (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.  A bug  bug12345.phpt (bug.php.net/12345)  Features  <functionname>_basic.phpt  Errors  <functionname>_error.phpt  General  extname<test nr>.phpt Naming convention
  • 8. --TEST— Not testing PHP --FILE— Goede morgen --EXPECT— Goede morgen Simplest test ever
  • 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. --TEST— rand --FILE— <?php echo “rand: ”. rand(); ?> --EXPECT— rand: %d Expect using printf syntax
  • 11. --TEST— rand --FILE— <?php echo “rand: ”. rand(); ?> --EXPECTREGEX— M_E: 2.718281[0-9]* Expect using regex syntax (avoid it)
  • 12. http://qa.php.net/expectf_details.php Where to find the EXPECTF placeholders list
  • 13. --TEST— Timezone --INI— date.timezone=Europe/Berlin --FILE— <?php echo date_timezone_get(); ?> --EXPECT— Europe/Berlin Custom ini settings
  • 14. --TEST— Timezone --SKIPIF— <?php if (! extension_loaded („myext‟) die(„myext not available‟); ?> --FILE— … --EXPECT— .. Conditional test
  • 15. --TEST— Timezone --CREDITS— John TheWriter #testfest Utrecht 2009 --FILE— … --EXPECT— .. Render unto Caesar the things which are Caesar’s
  • 16. http://qa.php.net/phpt_details.php Complete doc about phpt (with samples!)
  • 17. Keep it smalll and beautiful Test one feature per phpt Avoid large output What is a good test?
  • 18. If a large output is necessary Numerate or name each line Easier to analyze Easier to debug What is a good test?
  • 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

×