【发布时间】:2010-12-29 22:28:03
【问题描述】:
我想为函数库文件运行单元测试...
也就是说,我没有类,它只是一个包含辅助函数的文件...
例如,我在 ~/www/test 创建了一个 php 项目
还有一个文件 ~/www/test/lib/format.php
<?php
function toUpper( $text ) {
return strtoupper( $text );
}
function toLower( $text ) {
return strtolower( $text );
}
function toProper( $text ) {
return toUpper( substr( $text, 0, 1 ) ) . toLower( substr( $text, 1) );
}
?>
tools -> create PHPUnit tests 出现以下错误:
Sebastian Bergmann 的 PHPUnit 3.4.5。
在中找不到类“格式” “/home/sas/www/test/lib/format.php”。
现在,如果我(手动)编码文件 ~/www/test/tests/lib/FormatTest.php
<?php
require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../../lib/format.php';
class FormatTest extends PHPUnit_Framework_TestCase {
protected function setUp() {}
protected function tearDown() {}
public function testToProper() {
$this->assertEquals(
'Sebastian',
toProper( 'sebastian' )
);
}
}
?>
它工作正常,我可以运行它...
但如果我从 format.php 中选择测试文件,我会得到
所选源文件的测试文件 没找到
有什么想法吗?
感谢
sas
ps:另一个问题,有没有办法更新生成的测试而无需手动删除它们???
ps2:使用 netbeans 2.8 开发版
【问题讨论】:
-
能否给出两个文件的文件名和路径
-
当然,刚刚编辑了问题以添加该信息...
标签: php unit-testing netbeans phpunit