1
$ ../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

I am getting [1m and 30;43m, but I have no idea what they mean, unless they're some debug output that are basically meaningless.

Not sure what's wrong. I mean if there's something that went wrong, they should be more explicit. Here's my MemberTest class:

<?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'
    ];
}

}

I also made a fixture class, MemberFixture:

<?php 

namespace app\tests\codeception\fixtures;

use yii\test\ActiveFixture;

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

And a data class 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',
    ],


];

I also ran codecept build after changing the unit.suite.yml file:

# Codeception Test Suite Configuration

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

class_name: UnitTester
modules:
   enabled:
    - Asserts

I have no idea what's wrong. I am using Yii2 in case you haven't figured it out yet. I changed the Member class and tested it out by inserting Member elements with the form and everything to make sure my models and controllers worked fine, so I am completely clueless here.

1
  • 1
    the ←[30;43m and the like are shell colour codes, you appear to be using a terminal that does not support colours. Commented Jan 20, 2016 at 5:52

2 Answers 2

4

Test method was not executed, because it doesn't follow naming convention - the method name must begin with "test".

public function testBasic()
{
}

http://codeception.com/docs/05-UnitTests#Classical-Unit-Testing

Sign up to request clarification or add additional context in comments.

Comments

0

You should run single test with this command:

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

where unit it's suite name and models/MemberTest is path relative from unit suite folder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.