2012-03-26 171 views
1

我正在使用yii框架,並且我構建了一些測試。 通過硒測試數據庫和模型以及一個測試用戶界面。Phing運行Yii框架測試

我嘗試爲phing構建xml文件以運行此測試(我正在使用Jenkins)。 但phing不喜歡把phpunit.xml作爲配置。我的硒測試失敗了。

這是使用的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) 

這是使用Phing對於相同的測試日誌 - >

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

總時間:0.2542秒

這是PHPunit.xml配置 - >

<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> 

這是build.xml文件(Phing)配置 - >

<?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> 

如何,我可以運行詹金斯測試我的警予的項目?

回答

0

這是一個猜測,我從來沒有用過Yii。

我猜測,當你運行你的測試時,你從測試文件夾中運行它們。另外,當你運行phing時,你從項目的根目錄運行。

解決方案我認爲您需要告訴phing在測試文件夾中運行PHPUnit,而不是從根文件夾運行。