【问题标题】:Running Yii framework testing by PhingPhing 运行 Yii 框架测试
【发布时间】:2012-04-09 21:35:49
【问题描述】:

我正在使用 yii 框架并构建了一些测试。 一个测试数据库和模型,一个通过 selenium 测试用户界面。

我尝试为 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?

构建完成

总时间: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>

如何对我的 yii 项目运行 Jenkins 测试?

【问题讨论】:

    标签: yii phpunit jenkins phing


    【解决方案1】:

    这是一个猜测,我从未使用过 Yii。

    我猜当您运行测试时,您会从测试文件夹中运行它们。此外,当您运行 phing 时,您会从项目的根目录运行。

    要修复,我认为您需要告诉 phing 在测试文件夹中运行 PHPUnit,而不是从根文件夹中。

    【讨论】:

      猜你喜欢
      • 2011-12-16
      • 2013-08-03
      • 2012-03-22
      • 2014-05-26
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-30
      相关资源
      最近更新 更多