1

I have created a new Trait for testing my custom module and placed it in my_module/tests/src/Traits with the namespace Drupal\Test\my_module\Traits, the same as core modules do.

When I try to use this in my PHP Unit kernel test I just get the following error:

Fatal error: Trait 'Drupal\Test\my_module\Traits\CustomTrait' not found

Is there something special that needs to be included to allow custom traits in testing?

0

1 Answer 1

2

The namespace should Drupal\Tests\my_module\Traits - notice this is Tests with an s at the end, not Test

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.