我想使用setUpBeforeClass()来设置数据库连接,并进行一些日志记录,但是在我的测试执行之前(或者根本就没有)调用它.
我有以下几点:
class TestSetup extends PHPUnit_Extensions_SeleniumTestCase {
public static function setUpBeforeClass() {
//do some setup stuff here for all my tests
}
protected function setUp() {
$this->setbrowserUrl('http://' . $this->deviceIp);
}
protected function testOne() {
//do a test here
}
protected function testTwo() {
//do a test here
}
}
我做了一些深入研究PHPUnit / Frameworks / TestSuite.PHP的工作,并确认在660行上$this-> testCase是bool(false).但是我不知道它是否应该正确或应该在哪里发生(__construct()中除外).
我在这里有点不高兴,所以对您的帮助将不胜感激.
让我知道是否可以提供其他有用的信息.
乔希
解决方法:
在PHPUnit / Extensions / SeleniumTestCase.PHP运行方法(第289行)中,没有调用setUpBeforeClass(或可能这样做的任何其他方法)的迹象.
如果您认为这是一个问题,建议您从phpunits issue tracker
开始购票.
protected function setUp() {
static $db = null;
if($db === null) {
$db = whatevery_you_do_there();
}
$this->db = $db;
}
应该可以工作,就像您在setUpBeforeClass()中运行它一样
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。