2016-11-22 54 views
1

我尝试在Codeception中配置单元测试套件。当我运行套件Codeception失败,错误Fatal error: Cannot re-declare class rest\tests\UnitTester。通过调试器,我找到了第一次和第二次加载类的地方。代码。 Actor类加载两次

在向加载程序添加步骤期间,第一次加载到代码中的演员Codeception\Test\Loader\Gherkin

第二次为具有测试的类初始化Actor实例。第二,这个类必须已经包含在内,但是再次加载器被触发。这里出现错误。

Class加载了Codeception加载器。起初我认为它是由命名空间造成的,但UnitTester只是命名空间中的一个类。我的.yml文件列在下面。我会非常感激的帮助。

codeception.yml:

actor: Tester 
paths: 
    tests: tests 
    log: tests/_output 
    data: tests/_data 
    support: tests/_support 
    envs: tests/_envs 
settings: 
    bootstrap: _bootstrap.php 
    colors: true 
    memory_limit: 1024M 
modules: 
    config: 
     Yii2: 
      configFile: 'config/test-local.php' 

unit.suite.yml:

class_name: UnitTester 
    modules: 
     enabled: 
      - Yii2 
      - Asserts 

回答

0

我找到原因了这个问题。我的codeception.yml用于测试缺少名称空间参数,当测试文件夹中的类位于命名空间下时。这导致了我的问题。