I try to configure unit-tests suite in Codeception. When I run suite Codeception fail with error Fatal error: Cannot re-declare class rest\tests\UnitTester
. With debugger I located places where it loads class first and second time.
First time Codeception load Actor in Codeception\Test\Loader\Gherkin
during adding steps to loader.
Second time it initialize Actor
instance for class with tests. In second place this class must be already included, but again loader is triggered. Here error appear.
Class is loaded with Codeception loader. At first I think that it was caused by namespace, but UnitTester
is only one class in namespace. My .yml
files a listed below. I would be very grateful for help.
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
I found a reason of this problem. My codeception.yml
for this tests missing namespace param when classes in test folder was under namespace. This caused my problem.