【发布时间】:2011-06-30 04:27:51
【问题描述】:
如何在“PHP 内”运行测试而不是使用“phpunit”命令?示例:
<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class MySeleniumTest extends PHPUnit_Extensions_SeleniumTestCase {
protected function setUp() {
$this->setBrowser("*firefox");
$this->setBrowserUrl("http://example.com/");
}
public function testMyTestCase() {
$this->open("/");
$this->click("//a[@href='/contact/']");
}
}
$test = new MySeleniumTest();
//I want to run the test and get information about the results so I can store them in the database, send an email etc.
?>
或者我是否必须将测试写入文件,通过 system()/exec() 调用 phpunit 并解析输出? :(
【问题讨论】: