jeudi 20 avril 2017

Codeception can't find class when running single test

I'm writing the API test suite for a project I'm currently working on.

I can successfully run the suite using

codecept run api

and all the tests are passing successfully, but whenever I try running a single test using

codecept run api Tests\Users\Get

the following error is thrown:

PHP Fatal error: Class 'Tests\ApiCest' not found in /Users/Username/Programming/PHP/Project/tests/api/Tests/Users/GetCest.php on line 12

This is the folder structure I'm using:

Folder structure

The ApiCest.php is only used to quickly bootstrap the other tests. Here is its content:

namespace Tests;

/*
 * This class is extended by the API tests.
 */
use ApiTester;

class ApiCest
{
    public function _before(ApiTester $I)
    {
        $I->prepareRequest();
    }

    public function _after(ApiTester $I)
    {
        // All API responses must be in a JSON format.
        $I->seeResponseIsJson();
    }
}

And this is how it's used in the GetCest.php:

namespace Tests\Users;

use ApiTester;
use Codeception\Util\HttpCode;
use Tests\ApiCest;

/*
 * Tests for the GET /users API endpoint.
 */
class GetCest extends ApiCest
{
    // Tests methods are here but omitted
}

Aucun commentaire:

Enregistrer un commentaire