0
votes

I'm using yii framework and I build some tests. one test the database and model and one test ui by selenium.

I try to build xml file for phing to run this tests (I'm using Jenkins). But phing didn't like to take phpunit.xml as a configuration. and my selenium test fails.

This is log using phpunit ->

phpunit functional/signupTest.php 

PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from /var/www/myProject/protected/tests/phpunit.xml

............

Time: 01:29, Memory: 6.00Mb

OK (12 tests, 0 assertions)

This is log using Phing for the same test ->

    Buildfile: /var/www/myProject/protected/tests/build.xml

myProject > test:

  [phpunit] Testsuite: signupTest
  [phpunit] Tests run: 6, Failures: 0, Errors: 6, Incomplete: 0, Skipped: 0, Time elapsed: 0.05331 s
  [phpunit] testShow ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] testCreate ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] testUpdate ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] testDelete ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] testList ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] testAdmin ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] Testsuite: SiteTest
  [phpunit] Tests run: 3, Failures: 0, Errors: 3, Incomplete: 0, Skipped: 0, Time elapsed: 0.02317 s
  [phpunit] testIndex ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] testContact ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?
  [phpunit] testLoginLogout ERROR
  [phpunit] Invalid response while accessing the Selenium Server at 'http://localhost:4444/selenium-server/driver/': ERROR Server Exception: sessionId should not be null; has this session been started yet?

BUILD FINISHED

Total time: 0.2542 seconds

This is PHPunit.xml configuration ->

<phpunit bootstrap="bootstrap.php"
        colors="false"
        convertErrorsToExceptions="true"
        convertNoticesToExceptions="true"
        convertWarningsToExceptions="true"
        timeout="30000"
        stopOnFailure="false">

    <selenium>
        <browser name="Google Chrome" browser="*chrome" />
        <browser name="Firefox" browser="*firefox" />
    </selenium>

</phpunit>

This is build.xml (Phing) configuration ->

<?xml version="1.0" encoding="UTF-8"?>
<project name="myProject" default="test">

        <target name="test" description="Launch PHPUnit Testing">
                <phpunit bootstrap="bootstrap.php" printsummary="false">
                        <formatter type="plain" usefile="false"/>
                        <batchtest>
                                <fileset dir=".">
                                        <include name="unit/Test.php"/>
                                         <include name="functional/*Test.php"/>
                                </fileset>

                        </batchtest>
                </phpunit>
        </target>        
</project>

How can I run Jenkins test to my yii project?

1

1 Answers

0
votes

Here's a guess, I've never used Yii.

I'm guessing that when you run your tests you run them from the tests folder. Also that, when you run phing you run from the root of the project.

To fix I think you need to tell phing to run PHPUnit in the tests folder, not from the root folder.