On 9/22/05, J. Erik Heinz <[EMAIL PROTECTED]> wrote: > i tried to use agavi test. When i looked at the > Default_IndexActionTest i recognized the function testHasTests(). > > Is it the intesion to assign there the functions which should be > tested, ie: > > ... > public function testHasTests() > { > $this->testGetArray(); > } > > public function testGetArray() { > [somestuff] > $this->assertTrue($aArray); > } > ... > > As I am understood simpletest right, every function which will begin > with test.. will be tested, so normally the testHasTests is > unnecessary. Or is it just there, to remind you to write a test for > it?
yes, any method inside the test case that's name begins with 'test' will be executed as a test. The testHasTests() method is just put in there as a placeholder and to get your attention. Truth is, there may or may not be a need to write _unit_ tests for every or even any of the Actions. I had done a lot of work in creating a pretty detailed article on creating a module from start to finish while using TDD (http://trac.agavi.org/trac.cgi/ticket/22). But in doing so found many areas where things could be improved so I've been working on those improvements in the meantime. I'm going to pursue it again here very soon and see how things play out now. :) > How do you test, for example Default_IndexActionTest, if you have in > the Default_IndexAction class an construct like this: > $foo = $this->getContext()->getRequest()->getParameter('foo'); > normally i would get a error like: call to a member function on a > non-object... > > Do I have to write a Dummy object (Mock?), which will be taken > instead of the real object. But how do I do that and how do I assign > it to the test, that it will be used in the right place? There are ways.. I want to work through the excercise I explained above before I start advocating anything, though. -Mike _______________________________________________ agavi-dev mailing list agavi-dev@agavi.org http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev