简体   繁体   English

PHPunit,获取ZF控制器操作的功能代码覆盖率

[英]PHPunit, Getting function code coverage for a ZF controller action

I'm using PHPunit to test our Zend Framework project and it works allright but i'm not getting coverage om my action methods in my controllers. 我正在使用PHPunit测试我们的Zend Framework项目,它可以正常工作,但是我没有在我的控制器中覆盖我的操作方法。

Although I get coverage in number off lines of code but I want to have coverage on the functions/methods. 尽管我在代码行外获得了覆盖范围,但是我想对函数/方法进行覆盖。

I see a lot of examples on the internet where they just do it like this: 我在互联网上看到很多这样的示例:

class IndexTest extends Zend_Test_PHPUnit_ControllerTestCase
{
  public function testIndexAction() {
    $this->dispatch('/');
    $this->assertController('index');
    $this->assertAction('index');
    $this->assertXpath("//form[@action = '/index']");
  }
}

Which should work even if I look to this example from Jon: 即使我从Jon看这个例子,它也应该起作用:

http://www.zendcasts.com/unit-testing-with-the-zend-framework-with-zend_test-and-phpunit/2009/06/ http://www.zendcasts.com/unit-testing-with-the-zend-framework-with-zend_test-and-phpunit/2009/06/

http://code.google.com/p/zendcasts/source/browse/#svn/trunk/zc25-unit-testing http://code.google.com/p/zendcasts/source/browse/#svn/trunk/zc25-unit-testing

I'm doing it almost the exact way but it's not giving me any percentage of code coverage in functions, except for the init() function but I think that one is automaticly ignored by Zend Controller testcase. 我几乎以完全正确的方式来执行此操作,但是除了init()函数外,它没有给我任何百分比的代码覆盖率,但我认为Zend Controller测试用例会自动忽略其中的一个。

I'm I doing something stupid or doesn't PHPUnit reconize it's calling this action? 我正在做一些愚蠢的事情,或者PHPUnit不协调它正在调用此操作吗? Using PHPUnit 3.5.14 and Zend Framework 1.11.x 使用PHPUnit 3.5.14和Zend Framework 1.11.x

要从PHPunit获得特定功能的代码覆盖率,您需要确保函数的每一行都被测试调用,以便对所有可能的情况都进行处理和测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM