2008年10月14日星期二

Re: [fw-core] Zend_Test and login functionality

-- Steve Klabnik <steve@libsyn.com> wrote
(on Monday, 13 October 2008, 02:47 PM -0700):
>
> Hey everyone. I'm in the process of getting around to writing some unit tests
> for some code, finally. I hear it's never too late to start.
>
> Almost all of the code I want to test requires a user to be logged in first.
> And while I could just keep writing the log in stuff over and over again for
> each test, it seems a little tedious.
>
> The only previous unit testing that I've done in the past has been a small
> amount of Ruby on Rails, and restful_authentication. If I remember
> correctly, it provided a small helper function that you would call to log
> in, so that you wouldn't keep typing over and over.
>
> Can I do this with Zend_Test? If I write a funciton that doesn't start with
> test, it skips over it, right? Is this best practice for this sort of thing?
> Should I be coming up with a lot of these little helpers and collect them
> somewhere?

Absolutely do this. This is why test methods start with the word 'test'.

> Any sort of guidance on best practices associated with this kind of thing
> would be greatly appreciated. If I'm going to do something, I'd like to do
> it the right way from the start.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: