How Testing Changed My Life

Post on 17-May-2015

3.348 views 4 download

Tags:

description

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

Transcript of How Testing Changed My Life

Wordcamp san francisco, aug 13, 2011

HOW TESTING CHANGED MY LIFE

Nikolay bachiyski, automattic

Next30 minutes

0. what?

1. example plugin

2. do it yourself!

what?

Automated

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

0. what?

xUnit

0. what?

PHPUnithttp://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_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'  )  );        }

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

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 core2. 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!

FEAR!

FEAR!

warm & cozy > FEARwarm & cozy > FEAR