首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Phing运行Yii框架测试

通过Phing运行Yii框架测试
EN

Stack Overflow用户
提问于 2012-03-26 19:20:47
回答 1查看 1.4K关注 0票数 0

我正在使用yii框架,并构建了一些测试。一个测试数据库和模型,一个由selenium测试ui。

我尝试为phing构建xml文件以运行此测试(我使用的是Jenkins)。但是phing不喜欢把phpunit.xml作为一种配置。我的selenium测试失败了。

这是使用phpunit ->的日志

代码语言:javascript
复制
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的日志

代码语言:javascript
复制
    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 configuration ->

代码语言:javascript
复制
<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)配置->

代码语言:javascript
复制
<?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测试?

EN

回答 1

Stack Overflow用户

发布于 2012-03-27 01:33:36

我猜,我从来没用过Yii。

我猜当你运行你的测试时,你是从测试文件夹中运行它们的。另外,当你运行phing时,你是从项目的根开始运行的。

要解决这个问题,我认为你需要告诉phing在PHPUnit文件夹中运行测试,而不是从根文件夹中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9871165

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档