2014-08-31 65 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() { 
} 

應該工作

相關問題