小编ste*_*pop的帖子

PHPUnit代码覆盖率

我正在学习单元测试Zend Framework应用程序的绳索.到目前为止,我已经开始PHPUnit使用Zend Framework并开始编写一些简单的测试用例.

我的问题是,我想知道为什么Code Coverage不能在我的日志标记中设置为什么不起作用phpunit.xml.

我没有收到任何错误但没有生成覆盖率报告.

但是当我跑步时它会起作用 phpunit --coverage <dir>

我的phpunit的日志记录部分如下:

<phpunit bootstrap="./application/bootstrap.php" colors="true">
        <testsuite name="CI Test Suite">
            <directory>./</directory>
        </testsuite>
        <testsuite name="Library Test Suite">
            <directory>./library</directory>
        </testsuite>

        <filter>
            <whitelist>
                <directory suffix=".php">../application/</directory>
                <exclude>
                    <directory suffix=".phtml">../application</directory>
                    <file>../application/Bootstrap.php</file>
                    <file>../application/controllers/ErrorController.php</file>
                </exclude>
            </whitelist>
           <logging>
               <log type="coverage-html" target="./log/report" charset="UTF-8" yui="true"
   highlight="true" lowUpperBound="50" highLowerBound="80" />
               <log type="testdox" target="./log/testdox.html" />    
           </logging>
        </filter>
    </phpunit>
Run Code Online (Sandbox Code Playgroud)

有没有遇到过这个?什么是可能的问题?

php phpunit zend-framework code-coverage

13
推荐指数
1
解决办法
2万
查看次数

Symfony 3 FormTypeTest

按照Symfony 3.0手册测试表单类型,我按照以下示例测试了具有依赖关系的表单;

<?php
namespace Tests\AppBundle\Form;

use AppBundle\Form\Type\Database\OfficeAssignType;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\Test\TypeTestCase;

class OfficeTypeTest extends TypeTestCase
{
    private $entityManager;

    protected function setUp()
    {
    // mock any dependencies
    $this->entityManager = $this->getMock('Doctrine\Common\Persistence\ObjectManager');

    parent::setUp();
}

protected function getExtensions()
{
    // create a type instance with the mocked dependencies
    $office = new OfficeType($this->entityManager);

    return array(
        // register the type instances with the PreloadedExtension
        new PreloadedExtension(array($office), array()),
    );
}

public function testSubmitValid()
{
    $formData = array(
        'name' => 'new test office',
        'address1' => 'Test new office …
Run Code Online (Sandbox Code Playgroud)

php phpunit unit-testing symfony

6
推荐指数
1
解决办法
1024
查看次数