Simon Cornelius P Umacob wrote:
> Hello,
>
> What's the general way of writing unit tests in Agavi?  I want to get
> into the habit of writing tests while writing my code.
>
> I've examined the "test" folder in the Agavi source, but whenever I
> instantiate a class, I get a "class not found" error.  How can I
> automagically include my classes?
>
> Currently, I'm doing this in order to include the classes:
>
> $app_dir = AgaviConfig::get('core.app_dir');
> require_once "$app_dir/modules/FooBar/lib/action/FooBarBaseAction.class.php";
>
> class FooBarBaseActionTest extends AgaviPhpUnitTestCase
> {
>         public function testDoSomething()
>         {
>             $blah = new FooBarBaseAction();
>             // assert something something
>         }
> }
>
> Is this the correct way of doing it?  I have this feeling that it's
> not... my code looks like a temporary hack... =)
> /lists.agavi.org/mailman/listinfo/users
>   
Hi Simon,

I'm not really sure why you're trying to instantiate your 
FooBarBaseAction. Correct me if I'm wrong,
but I'm thinking you should actually be doing a flow-test here? Basic 
unit-tests don't really make much
sense with actions, as they require a truckload of other stuff to 
actually DO anything, and what they do
in the end is pretty much just tell you what view to render (ie. they 
only return a string).

Have a look at the flow-test sample in the sample application, it should 
be rather simple to figure out.


Hope this at least helps a bit,
Markus

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to