How Testing Changed My Life

24

description

Reasoning behind automated testing with a WordPress plugin as an example. Very mild exposure to bears.

Transcript of How Testing Changed My Life

Page 1: How Testing Changed My Life
Page 2: How Testing Changed My Life

Wordcamp san francisco, aug 13, 2011

HOW TESTING CHANGED MY LIFE

Nikolay bachiyski, automattic

Page 3: How Testing Changed My Life

Next30 minutes

Page 4: How Testing Changed My Life

0. what?

Page 5: How Testing Changed My Life

1. example plugin

Page 6: How Testing Changed My Life

2. do it yourself!

Page 7: How Testing Changed My Life

what?

Page 8: How Testing Changed My Life

Automated

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

0. what?

Page 9: How Testing Changed My Life

xUnit

0. what?

Page 10: How Testing Changed My Life

PHPUnithttp://www.phpunit.de/manual/current/en/

0. what?

Page 11: How Testing Changed My Life

class  WP_Is_Email_Test  extends  WP_UnitTestCase  {

}

       function  test_is_email_only_letters_with_dot_com_domain()  {                $this-­‐>assertEquals(  '[email protected]',  is_email(  '[email protected]'  )  );        }                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(  '[email protected]',  is_email(  '[email protected]'  )  );        }

0. what?

Page 12: How Testing Changed My Life

class  WP_Is_Email_Test  extends  WP_UnitTestCase  {

}

       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(  '[email protected]',  is_email(  '[email protected]'  )  );        }

       function  test_is_email_only_letters_with_dot_com_domain()  {                $this-­‐>assertEquals(  '[email protected]',  is_email(  '[email protected]'  )  );        }        

0. what?

Page 13: How Testing Changed My Life

0. what?

Page 14: How Testing Changed My Life

Example Plugin

WP_Bearify

Page 15: How Testing Changed My Life

do it yourself!

2. do it yourself!

Page 16: How Testing Changed My Life

Grab the Framework

https://github.com/nb/wordpress-tests

soon in core2. do it yourself!

Page 18: How Testing Changed My Life

PHPUnit

http://www.phpunit.de/manual/current/en/

2. do it yourself!

Page 19: How Testing Changed My Life

PHPUnit in your editor

https://github.com/meritt/phpunit-tmbundle/https://github.com/klokane/vim-phpunit

2. do it yourself!

Page 20: How Testing Changed My Life
Page 21: How Testing Changed My Life

FEAR!

Page 22: How Testing Changed My Life

FEAR!

Page 24: How Testing Changed My Life

warm & cozy > FEARwarm & cozy > FEAR