2014-08-31 45 views
0

我创建了一个codeception单元测试:codeception单元测试仅用于公共函数运行TESTME

<?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 

但唯一的测试呼叫是 - > TESTME 并且它不运行 - > checkLimit

它们都是公共的。

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

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

回答

5

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

测试都是公用方法,命名为测试*。

或者,您可以在方法的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() { 
} 

应该工作