Thursday, December 31, 2009

Re: testing a controller's add action

I don't have an issue if someone wants to copy/paste/modify the
article I wrote into the book. There is no need to file tickets about
improving the documentation on testing, you can simply edit/add to the
existing documentation instead. testAction as you are aware is
exceptionally limited in what it is capable of doing, and regular
testing methods are clearer and easier to work with.

I also use mocks in my controller tests, and covered using mocks in a
different post too. http://www.mark-story.com/posts/view/testing-cakephp-controllers-mock-objects-edition.
I find I usually mock Auth, Session and Email components as they are
the most disruptive to automated testing.

As for planned improvements to the test suite, I didn't really have
much planned, there are some fixes and improvements to be done with
the code coverage, but as far as making controller testing easier, I
didn't have anything planned.

-Mark

On Dec 29, 4:04 am, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
> Thanks for all the information!
>
> Let's see how testing is in the next release, and in particular the
> documentation; as for proposing an alternative in the book I guess I
> should file a ticket, right?
>
> For the moment I'm testing controllers' actions the "hard way" :)
>
> cheers
>         Lorenzo
>
>
>
>
>
> nurvzy wrote:
> > Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
> >> I'm not getting errors: as I said before, I can see that data is not
> >> populated using the debugger, and also because it executes the
> >> instructions to be executed when data is null; thus it basically does
> >> not faulter, it simply does not get any data...  can it be a bug?
>
> > It's possible, I never had a whole lot of luck with testAction other
> > than just really basic tests, as such I almost never use it.  It's
> > possible we're missing something really simple.  /shrug.  testAction
> > does a lot of the 'magic' on it own, but I prefer doing things in such
> > a way I have complete control over the test -- less surprises that
> > way.  I read, in 1.3/2.0 the testsuite is getting a major makeover.
>
> >> yes, with the instructions in this post I can successfully test mycontroller'sadd and edit actions.
>
> >> But I guess the documentation of cakephp should be updated to include
> >> such way oftestingcontrollers, especially since testAction, as you
> >> also noticed, is not powerful enough (and probably buggy due to the
> >> missing data ;)
>
> > I agree, I like the way Mark tests his controllers, it makes a lot
> > more sense to me.   If you're feeling generous go ahead and post an
> > alternative in the Book, they always like people helping them make the
> > documentation better.
>
> --
> Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
> HOME:http://www.lorenzobettini.itMUSIC:http://www.purplesucker.com
> BLOGS:http://tronprog.blogspot.com http://longlivemusic.blogspot.com

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: