Release early, Release often, CakeTaster

Posted by Felix Geisendörfer, on Nov 16, 2006 - in PHP & CakePHP » Testing, Debugging & Refactoring

Deprecated post

The authors of this post have marked it as deprecated. This means the information displayed is most likely outdated, inaccurate, boring or a combination of all three.

Policy: We never delete deprecated posts, but they are not listed in our categories or show up in the search anymore.

Comments: You can continue to leave comments on this post, but please consult Google or our search first if you want to get an answer ; ).

Ok I just realized that I've been following a bad pattern on two of my little side projects. The pattern of not releasing before everything is as 'perfect' and feature complete as it can be. Those projects are the CakeTaster test suite and also my Svn/Ftp Deployment Task for bake.

I guess the reason for that is that my blog has turned into my #1 resource for marketing myself since I've started it in January. This causes me to feel hesitant about publishing things that are unfinished, might have bad bugs in them and could make myself look like a poor programmer. Well, the truth is, the poorest programmer of all is the ones that doesn't release. Because what good am I doing to the world when tinkering for for month on things people are in bad need for today, just to make myself look like all code I ever write is perfect the first time. None at all. Therefor I just took 20 minutes, cleaned up the current code of the CakeTaster test suite and decided to release it.

Download: You can download the 0.1 experimental release of CakeTaster here.
Install: Installing the testsuite is simply a matter of unzipping the zip file and copying it over your existing application code. But just to be sure you should take a look in the folder before in order to make sure you don't accidentally overwrite an own controller.
Usage: There is only one kind of testing available right now, the functional testing of Controllers. There are already two sample tests inside the zip file, they will end up resting in /app/tests/functional and should serve as a good example of what a ControllerTest looks like. But just in case you are too lazy to download the package, here is one of the tests:

php
  1. require_once dirname(__FILE__).'/../../../vendors/caketaster/functional.php';
  2.  
  3. class PostsControllerTest extends ControllerTestCase
  4. {        
  5.     function test_index()
  6.     {
  7.         $response = $this->get('/posts/index');
  8.         $vars     = $this->viewVars;
  9.        
  10.         $this->assertTrue(!empty($vars['posts']), 'Posts array is not empty');        
  11.         $this->assertTrue(true, 'True === True');
  12.     }
  13. }
  14.  
  15. CakeTaster::runTest();

As you can see $this->get invokes a call to a given url, there is also a post functional as well as a parameter for arguments which I haven't tested so far. The class itself extends the UnitTestCase of SimpleTest and therefor supports all kinds of asserts that SimpleTest does. The get/post function will always contain the view rendered by the Controller, and $this->viewVars will contain, uhm, the view vars ; ).

In order to run the tests you have to browse to /tests. It should give a little interface allowing to filter for test names as well as to expand/collapse certain tests.

And for those of you who want to see what they are getting into before doing so, here comes a little screen shot:

CakeTaster

Alright, I would love to hear any kind of feedback on the suite. I know it's not even close to being done but the basics are there. So if you find a bug, want to make a suggestion or something like this, let me know in the comments.

--Felix Geisendörfer aka the_undefined