SlideShare a Scribd company logo
1 of 14
Download to read offline
Enrise mini testfest
february - 2011
What is a Testfest?



        Fun gathering for PHP programmers
        and the like.
        Concentrating on writing unit tests.
        Making PHP better.
        Get your name into PHP credits.
        Drink free beer.

∂ WHAT IS IN IT FOR ME?
What is OUR Testfest?




 Mini test fest (evening instead of a full day)
 Maybe more often?
 Maybe full days?
 You decide,..
How to write a test (1)




     Simple text file with a bit of PHP code
     Test each component separately
     One test per .PHPT file
How to write a test (2)




       Bug: bug1234.phpt
       Feature: <function>_basic.phpt
       Error: <function>_error.phpt
       Global: <extension><nr>.phpt



∂ NAMING CONVENTIONS
How to write a test (3)


        --TEST--
        --CREDITS--
        --SKIPIF--
        --FILE--
        --EXPECT-- / --EXPECTF--
        --CLEAN--

∂ PHPT SECTIONS
How to write a test (4)


    --TEST--
    Trivial "Hello World" test
    --FILE--
    <?php echo "Hello World"?>
    --EXPECT--
    Hello World



∂ EXAMPLE TEST (test/basic/001.phpt)
How to write a test (5)



    --TEST--
    Check if echo works
    --CREDITS--
    Joshua Thijssen <jthijssen@enrise.com>
    # Enrise TestFest 2011-02-11
    --FILE--
    <?php echo "Hello World"?>
    --EXPECT--
    Hello World




∂ EXAMPLE TEST
How to run your tests (1)




∂ HTTP://TESTFEST.ENRISE.COM
How to run your tests (2)
What to test?



  http://gcov.php.net/PHP_5_3/lcov_html/

      DOM (67.8%)               STANDARD (78.1%)
      IMAP (64.4%)              OPENSSL (63.1%)
      FTP (60.0%)               SQLITE (74.7%)
      SNMP (7.8%)               ZIP (65.4%)


∂ HIGHER CODE COVERAGE DOES NOT ALWAYS MEAN BETTER TESTS!
More information



     Check out the URL’s:

        http://qa.php.net/write-test.php
        http://qa.php.net/phpt_details.php
        http://gcov.php.net/




∂ MORE INFO ABOUT PHP UNIT-TESTING
More information




        When in doubt, ask one us to help you!




∂ WE ARE HERE TO HELP!
∂ LET’S SQUASH SOME BUGS

More Related Content

Viewers also liked

PFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedPFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedJoshua Thijssen
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfzJoshua Thijssen
 
Alice & bob public key cryptography 101
Alice & bob  public key cryptography 101Alice & bob  public key cryptography 101
Alice & bob public key cryptography 101Joshua Thijssen
 
Alice & bob public key cryptography 101
Alice & bob  public key cryptography 101Alice & bob  public key cryptography 101
Alice & bob public key cryptography 101Joshua Thijssen
 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionJoshua Thijssen
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line toolsEric Wilson
 
Sed & awk the dynamic duo
Sed & awk   the dynamic duoSed & awk   the dynamic duo
Sed & awk the dynamic duoJoshua Thijssen
 

Viewers also liked (11)

PFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - AdvancedPFZ WorkshopDay Linux - Advanced
PFZ WorkshopDay Linux - Advanced
 
15 protips for mysql users pfz
15 protips for mysql users   pfz15 protips for mysql users   pfz
15 protips for mysql users pfz
 
Alice & bob public key cryptography 101
Alice & bob  public key cryptography 101Alice & bob  public key cryptography 101
Alice & bob public key cryptography 101
 
Cipher block modes
Cipher block modesCipher block modes
Cipher block modes
 
Awk programming
Awk programming Awk programming
Awk programming
 
Czzawk
CzzawkCzzawk
Czzawk
 
Alice & bob public key cryptography 101
Alice & bob  public key cryptography 101Alice & bob  public key cryptography 101
Alice & bob public key cryptography 101
 
Naive Bayes
Naive Bayes Naive Bayes
Naive Bayes
 
Puppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 EditionPuppet for dummies - ZendCon 2011 Edition
Puppet for dummies - ZendCon 2011 Edition
 
Unix command-line tools
Unix command-line toolsUnix command-line tools
Unix command-line tools
 
Sed & awk the dynamic duo
Sed & awk   the dynamic duoSed & awk   the dynamic duo
Sed & awk the dynamic duo
 

Enrise testfest

  • 2. What is a Testfest? Fun gathering for PHP programmers and the like. Concentrating on writing unit tests. Making PHP better. Get your name into PHP credits. Drink free beer. ∂ WHAT IS IN IT FOR ME?
  • 3. What is OUR Testfest? Mini test fest (evening instead of a full day) Maybe more often? Maybe full days? You decide,..
  • 4. How to write a test (1) Simple text file with a bit of PHP code Test each component separately One test per .PHPT file
  • 5. How to write a test (2) Bug: bug1234.phpt Feature: <function>_basic.phpt Error: <function>_error.phpt Global: <extension><nr>.phpt ∂ NAMING CONVENTIONS
  • 6. How to write a test (3) --TEST-- --CREDITS-- --SKIPIF-- --FILE-- --EXPECT-- / --EXPECTF-- --CLEAN-- ∂ PHPT SECTIONS
  • 7. How to write a test (4) --TEST-- Trivial "Hello World" test --FILE-- <?php echo "Hello World"?> --EXPECT-- Hello World ∂ EXAMPLE TEST (test/basic/001.phpt)
  • 8. How to write a test (5) --TEST-- Check if echo works --CREDITS-- Joshua Thijssen <jthijssen@enrise.com> # Enrise TestFest 2011-02-11 --FILE-- <?php echo "Hello World"?> --EXPECT-- Hello World ∂ EXAMPLE TEST
  • 9. How to run your tests (1) ∂ HTTP://TESTFEST.ENRISE.COM
  • 10. How to run your tests (2)
  • 11. What to test? http://gcov.php.net/PHP_5_3/lcov_html/ DOM (67.8%) STANDARD (78.1%) IMAP (64.4%) OPENSSL (63.1%) FTP (60.0%) SQLITE (74.7%) SNMP (7.8%) ZIP (65.4%) ∂ HIGHER CODE COVERAGE DOES NOT ALWAYS MEAN BETTER TESTS!
  • 12. More information Check out the URL’s: http://qa.php.net/write-test.php http://qa.php.net/phpt_details.php http://gcov.php.net/ ∂ MORE INFO ABOUT PHP UNIT-TESTING
  • 13. More information When in doubt, ask one us to help you! ∂ WE ARE HERE TO HELP!
  • 14. ∂ LET’S SQUASH SOME BUGS

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n