Did you use yiic webapp command to generate your application?
If so, there’s a bootstrap file (protected/tests/bootstrap.php) that loads Yii class (framework/yii.php) , and instantiates CWebApplication. Just always launch phpunit from directory protected/tests or use --bootstrap (or --configuration) option.
If no, you have to write a bootstrap file manually.