SlideShare a Scribd company logo
How Testing Changed My Life
HOW TESTING
CHANGED MY LIFE

 Nikolay bachiyski, automattic
Wordcamp san francisco, aug 13, 2011
Next
30 minutes
0. what?
1. example
   plugin
2. do it yourself!
what?
0. what?




Automated

    http://www.flickr.com/photos/binaryape/4882162452/
xUnit


        0. what?
PHPUnit
http://www.phpunit.de/manual/current/en/



                                   0. what?
class  WP_Is_Email_Test  extends  WP_UnitTestCase  {

        function  test_is_email_only_letters_with_dot_com_domain()  {
                $this-­‐>assertEquals(  'nb@nikolay.com',  is_email(  'nb@nikolay.com'  )  );
        }
        
        function  test_is_email_should_not_allow_missing_tld()  {
                $this-­‐>assertFalse(  is_email(  'nb@nikolay'  )  );
        }
        
        function  test_is_email_should_allow_bg_domain()  {
                $this-­‐>assertEquals(  'nb@nikolay.bg',  is_email(  'nb@nikolay.bg'  )  );
        }

}




                                                                                       0. what?
class  WP_Is_Email_Test  extends  WP_UnitTestCase  {

        function  test_is_email_only_letters_with_dot_com_domain()  {
                $this-­‐>assertEquals(  'nb@nikolay.com',  is_email(  'nb@nikolay.com'  )  );
        }
        
        function  test_is_email_should_not_allow_missing_tld()  {
                $this-­‐>assertFalse(  is_email(  'nb@nikolay'  )  );
        }
        
        function  test_is_email_should_allow_bg_domain()  {
                $this-­‐>assertEquals(  'nb@nikolay.bg',  is_email(  'nb@nikolay.bg'  )  );
        }

}




                                                                                        0. what?
0. what?
Example Plugin

    WP_Bearify
do it yourself!


              2. do it yourself!
Grab the
      Framework
https://github.com/nb/wordpress-tests


            soon in core
                               2. do it yourself!
Please, read
  http://xunitpatterns.com/

      at least Narratives:
http://xunitpatterns.com/Book
        %20Outline.html

                              2. do it yourself!
PHPUnit
http://www.phpunit.de/manual/current/en/


                                2. do it yourself!
PHPUnit in your
         editor
https://github.com/meritt/phpunit-tmbundle/
  https://github.com/klokane/vim-phpunit
                                  2. do it yourself!
How Testing Changed My Life
FEAR!
FEAR!
http://www.flickr.com/photos/eebrierley/5394195199/
warm & cozy > FEAR

More Related Content

How Testing Changed My Life

  • 2. HOW TESTING CHANGED MY LIFE Nikolay bachiyski, automattic Wordcamp san francisco, aug 13, 2011
  • 5. 1. example plugin
  • 6. 2. do it yourself!
  • 8. 0. what? Automated http://www.flickr.com/photos/binaryape/4882162452/
  • 9. xUnit 0. what?
  • 11. class  WP_Is_Email_Test  extends  WP_UnitTestCase  {        function  test_is_email_only_letters_with_dot_com_domain()  {                $this-­‐>assertEquals(  'nb@nikolay.com',  is_email(  'nb@nikolay.com'  )  );        }                function  test_is_email_should_not_allow_missing_tld()  {                $this-­‐>assertFalse(  is_email(  'nb@nikolay'  )  );        }                function  test_is_email_should_allow_bg_domain()  {                $this-­‐>assertEquals(  'nb@nikolay.bg',  is_email(  'nb@nikolay.bg'  )  );        } } 0. what?
  • 12. class  WP_Is_Email_Test  extends  WP_UnitTestCase  {        function  test_is_email_only_letters_with_dot_com_domain()  {                $this-­‐>assertEquals(  'nb@nikolay.com',  is_email(  'nb@nikolay.com'  )  );        }                function  test_is_email_should_not_allow_missing_tld()  {                $this-­‐>assertFalse(  is_email(  'nb@nikolay'  )  );        }                function  test_is_email_should_allow_bg_domain()  {                $this-­‐>assertEquals(  'nb@nikolay.bg',  is_email(  'nb@nikolay.bg'  )  );        } } 0. what?
  • 14. Example Plugin WP_Bearify
  • 15. do it yourself! 2. do it yourself!
  • 16. Grab the Framework https://github.com/nb/wordpress-tests soon in core 2. do it yourself!
  • 17. Please, read http://xunitpatterns.com/ at least Narratives: http://xunitpatterns.com/Book %20Outline.html 2. do it yourself!
  • 19. PHPUnit in your editor https://github.com/meritt/phpunit-tmbundle/ https://github.com/klokane/vim-phpunit 2. do it yourself!
  • 21. FEAR!
  • 22. FEAR!
  • 24. warm & cozy > FEAR