Could you help me about the TDD case?

I’m sure my config file is correct and webapp is running well. I just want to try unit test, so I made a test case like this:




<?php

class DbTest extends CTestCase

{

  function testConnection(){

    $this->assertNotEquals(NULL, Yii::app()->db);

  }

}

?>

run: phpunit unit/DbTest

but result is:


There was 1 error:


1) DbTest::testConnection

CDbException: CDbConnection failed to open the DB connection.


/Applications/MAMP/htdocs/yii/framework/db/CDbConnection.php:293

/Applications/MAMP/htdocs/yii/framework/db/CDbConnection.php:260

/Applications/MAMP/htdocs/yii/framework/db/CDbConnection.php:238

/Applications/MAMP/htdocs/yii/framework/base/CModule.php:372

/Applications/MAMP/htdocs/yii/framework/base/CModule.php:86

/Applications/MAMP/htdocs/blog/protected/tests/unit/DbTest.php:5


FAILURES!

Tests: 1, Assertions: 0, Errors: 1.

Where I should go, can anybody give me some hints? thanks a lot!

check the db connection on the protected/config/console.php, make sure db is set under component, example




return array(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Console Application',

	...

	'components'=>array(

		'db'=>array(

			...

		),

	),

        ...

);



Thank you for your time, but the problem still there, even I re-configured the console.php rely on my connection situation:(

Resolved just change test config from ‘localhost’ into ‘127.0.0.1’ in connection section.Don’t know why main.php localhost works but test.php not.

i think the right config file is config/test.php

whoops you are right, thanks!