2016-01-20 89 views
0
$ ../vendor/bin/codecept run codeception/unit/models/MemberTest.php 
Codeception PHP Testing Framework v2.0.16 
Powered by PHPUnit 4.7.7 by Sebastian Bergmann and contributors. 

←[1mUnit Tests (0) ←[22m------------------------------ 
--------------------------------------------- 


Time: 2.99 seconds, Memory: 10.25Mb 

←[30;43mNo tests executed!←[0m 

我得到[1分和30;43米,但我不知道他們的意思,除非他們是一些調試輸出基本上是毫無意義的。Codeception:沒有測試執行

不知道什麼是錯的。我的意思是如果出現了問題,他們應該更加明確。這是我的MemberTest類:

<?php 

namespace tests\codeception\unit\models; 

use yii\codeception\TestCase; 
use app\models\Member; 

class MemberTest extends TestCase { 

public function basicTest() 
{ 
    $John = Member::findOne(['nickname'=>'John']); 
    $this->assertNotNull($John); 
} 

public function fixtures() 
{ 
    return [ 
    'members' => 'app\tests\codeception\fictures\MemberFixture' 
    ]; 
} 

} 

我也做了一個夾具類,MemberFixture:

<?php 

namespace app\tests\codeception\fixtures; 

use yii\test\ActiveFixture; 

class MemberFixture extends ActiveFixture 
{ 
    public $modelClass = 'app\models\Member'; 
} 

和數據類成員:

<?php 

return [ 
    [ 
     'id' => 1, 
     'firstName' => 'John', 
     'lastName' => 'Bush', 
     'email' => '[email protected]', 
     'username' => 'Warmonger', 
     'password' => 'allo', 
    ], 
    [ 
     'id' => 2, 
     'firstName' => 'Jane', 
     'lastName' => 'Bush', 
     'email' => '[email protected]', 
     'username' => 'PluckedFlower', 
     'password' => 'allo', 
    ], 


]; 

我也跑了改變單位後codecept建設.suite.yml文件:

# Codeception Test Suite Configuration 

# suite for unit (internal) tests. 
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 

class_name: UnitTester 
modules: 
    enabled: 
    - Asserts 

我不知道什麼是錯的。如果你還沒有弄清楚,我正在使用Yii2。我更改了會員類,並通過將表單和所有內容插入成員元素以確保我的模型和控制器正常工作,從而對其進行了測試,因此我在此完全無能爲力。

+1

的'←[30; 43m'等是外殼的顏色代碼,則可能在使用不支持顏色的終端。 – sevenseacat

回答

0

你應該用這個命令運行單個測試:

../vendor/bin/codecept run unit models/MemberTest 

其中unit它的套件名稱和models/MemberTestunit套件文件夾路徑相對。