Php 是否可以在安装夹具中获得当前测试?
我找不到这样的东西,我猜它不存在Php 是否可以在安装夹具中获得当前测试?,php,phpunit,fixtures,Php,Phpunit,Fixtures,我找不到这样的东西,我猜它不存在 class Test extends PHPUnit_Framework_TestCase { public function setUp() { echo $current_test; // Output a string "testOne" } public function testOne() { // This is the first test; before this test is ran
class Test extends PHPUnit_Framework_TestCase {
public function setUp() {
echo $current_test; // Output a string "testOne"
}
public function testOne() {
// This is the first test; before this test is ran setUp() is called.
// The question is, is there any way to know within setUp() what the
// current test is?
}
}
$this->name
应该包含当前的testcase方法名。您可以使用$this->getName()
访问它(正如David善意地指出的那样)
在上查看TestCase的API。浏览属性及其注释,了解可用的内容。
$name
已更改为private,因此您需要使用$this->getName()
。实际上,源代码是查找可用内容的最佳方法。:)