papaiatis
papaiatis

Reputation: 4291

Phing avoids Selenium browser settings in PHPUnit configuration

I setup up a phing project with two targets: the first runs phpunit test cases that includes selenium server as well and the second generates phpunit test reports using phpunitreport task.

phpunit task is configured to use an external configuration file called "phpunit-config.xml". This config XML file has a <selenium /> tag where two browsers are defined. This browser settings are not being processed therefore I am getting an exception from Selenium RC Server: "Browser not supported:" - please note the empty browser name here.

If I run phpunit directly from command line with the same configuraiton XML file everything works as expected.

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>

Not working scenario:

phing -buildfile phing-build.xml

Working scenario:

phpunit --configuration phpunit-config.xml functional\

In the not working scenario I'm getting the following error message from Selenium RC server:

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>

Any suggestions?

I have also raised a ticket for this: http://www.phing.info/trac/ticket/983

Upvotes: 1

Views: 359

Answers (1)

Ben
Ben

Reputation: 57287

For inquiring minds, the discussion in the ticket resolves this question:

Thanks for the report! Our phpunit task does not yet support the tag, so I'm going to mark this as an enhancement, not a defect :)

Upvotes: 0

Related Questions