Phing避免了PHPUnit配置中的Selenium浏览器设置

时间:2013-02-25 15:49:43

标签: selenium phpunit phing

我设置了一个包含两个目标的phing项目:第一个运行包含selenium服务器的phpunit测试用例,第二个使用phpunitreport任务生成phpunit测试报告。

phpunit任务配置为使用名为“phpunit-config.xml”的外部配置文件。此配置XML文件具有<selenium />标记,其中定义了两个浏览器。此浏览器设置未被处理,因此我从Selenium RC Server获得例外:“Browser not supported:” - 请注意此处的空浏览器名称。

如果我直接从命令行运行phpunit,使用相同的configuraiton XML文件,一切都按预期工作。

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

1 个答案:

答案 0 :(得分:0)

对于询问的人来说,故障单中的讨论解决了这个问题:

  

感谢您的举报!我们的phpunit任务还不支持    标签,所以我要将其标记为增强,而不是   缺陷:)