codeception单元测试仅针对公共函数testMe运行

时间:2014-08-31 13:47:38

标签: php unit-testing codeception

我创建了一个代码单元测试:

<?php


use Something\SiteResultsHolder;

class ResultHolderTest extends \Codeception\TestCase\Test
{
   /**
    * @var \UnitTester
    */
    protected $tester;

    protected function _before()
    {
    }

    protected function _after()
    {
    }

    // tests
    public function testMe()
    {
        //this test run

    }

    public function checkLimit() {
       //this test doesn't run
    }
}

我在终端呼叫:

codecept run unit

但唯一的测试电话是 - &gt;考验我 并且它没有运行 - &gt; checkLimit

他们都是公开的。

当我进行验收测试时,所有公共方法都是不同的测试,但在这里它似乎不起作用。

如何在那里添加测试?那将被称为?

1 个答案:

答案 0 :(得分:5)

根据PhpUnit 4.2文档(https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html):

  

测试是公共方法,名为test *。

     

或者,您可以在方法的docblock中使用@test注释将其标记为测试方法。

\Codeception\TestCase\Test扩展了\Codeception\TestCase,扩展了\PHPUnit_Framework_TestCase

因此,您实际上正在使用PHPUnit。您可以使用phpunit文档作为参考(https://phpunit.de/manual/current/en/index.html)。

在你的情况下:

public function testCheckLimit() {
}

/**
 * @test
 */
public function checkLimit() {
}

应该有效