2009年9月27日星期日

Re: [fw-mvc] How to start a test?

-- huajun qi <qihjun@gmail.com> wrote
(on Sunday, 27 September 2009, 10:28 AM +0800):
> I read the guide reference about testing, and I think it's different
> from usual unit test, it is integrated into the frame, isn't it?
>
> If I just want to test a class, but it refers to database, how can I
> do it?

For normal unit testing, you can use the unit testing framework of your
choice: PHPUnit, SimpleTest, phpt, etc.

What ZF provides are some PHPUnit extensions that allow you to test your
MVC applications and/or code that utilizes Zend_Db; these are found in
Zend_Test_PHPUnit_ControllerTestCase and Zend_Test_PHPUnit_Db,
respectively

> Does the test classes zf provides need to start the application?

For MVC application testing, yes -- you need to bootstrap your
application, and then use the methods in the ControllerTestCase to
dispatch actions and test against the response.

For testing code that utilizes Zend_Db -- for instance, your models
and/or service layer -- you can either use the DatabaseTestCase or the
DB mixin support to bootstrap the database connection.

> And I prefet to use simpletest framework, can it be deployed well?

It can -- but we have no official support for it within the framework.

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

没有评论: