我设置了一个包含两个目标的phing项目:第一个运行phpunit
包含selenium服务器的测试用例,第二个用phpunitreport
任务生成phpunit测试报告。Phing避免PHPUnit配置中的Selenium浏览器设置
phpunit任务被配置为使用名为“phpunit-config.xml
”的外部配置文件。这个配置XML文件有一个<selenium />
标签,其中定义了两个浏览器。这个浏览器设置没有被处理,因此我从Selenium RC Server得到一个异常:“Browser not supported:
” - 请注意这里的空白浏览器名称。
如果我直接从命令行使用相同的配置XML文件运行phpunit,一切都按预期工作。
phing-build.xml文件:
<project name="test-and-report" default="gen-report" basedir=".">
<target name="gen-report" depends="run-tests" >
<phpunitreport infile="report-junit.xml" format="frames" todir="report-phing" styledir="xsl/">
</phpunitreport>
</target>
<target name="run-tests">
<phpunit configuration="phpunit-config.xml">
<formatter type="xml" outfile="report-junit.xml"></formatter>
<batchtest>
<fileset dir="functional">
<include name="functional/**/*Test.php" />
</fileset>
</batchtest>
</phpunit>
</target>
PHPUnit的-config.xml中:
<phpunit bootstrap="bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false">
<selenium>
<browser name="Internet Explorer" browser="*iexplore" />
<browser name="Firefox" browser="*firefox" />
</selenium>
</phpunit>
不工作的情况:
phing -buildfile phing-build.xml
工作场景:
phpunit --configuration phpunit-config.xml functional\
在不工作的情况下,我从Selenium RC的服务器收到以下错误信息:
16:31:43.746 INFO - Command request: getNewBrowserSession[, http://localhost:8001 /index-test.php/] on session null
16:31:43.746 INFO - creating new remote session
16:31:43.746 INFO - Got result: Failed to start new browser session: java.lang.RuntimeException: Browser not supported:
(Did you forget to add a *?)
Supported browsers include:
*firefox
*mock
*firefoxproxy
<cutted here>
有什么建议?
我也提出了这个票:http://www.phing.info/trac/ticket/983