The BLT/Behat-related classes from the tests/src and tests/contexts subdirectories are being autoloaded by composer and are interfering with stand-alone Behat testing.

As I understand it, these test classes are now deprecated and were left in the codebase for backwards compatibility.

This patch removes the autoload so the classes will no longer be loaded by default.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cameron prince created an issue. See original summary.

cameron prince’s picture

Issue summary: View changes
cameron prince’s picture

phenaproxima’s picture

Title: Remove deprecated test classes » Don't autoload deprecated Behat support code
Category: Support request » Task
Status: Active » Reviewed & tested by the community

The last time the Behat stuff was touched was, apparently, over 2 years ago. And it's adorned with a strongly worded warning that it is old, deprecated, and not to be used.

Since this is causing autoloader issues in the wild, I think it's high time that we removed these classes from the autoloader. The files can stay, for the time being, in case there are naughty projects out there which are using them. But I think more than enough time has passed to require people who are still using this stuff to add it to their own autoloader (and hopefully, to their own project, natively).

Therefore, this patch looks good to me. I'll roll a new minor release after committing it.

phenaproxima’s picture

phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x-5.x. Thanks!

sylus’s picture

I was getting the following so i just did this quick rename which seemed to resolve :)

Fatal error: Trait "Acquia\LightningExtension\Context\AwaitTrait" not found in /var/www/html/modules/contrib/lightning_core/tests/contexts/ViewsContext.behat.inc on line 16
make: *** [docker/Makefile:24: behat] Error 255
Error: Process completed with exit code 2.
skirtley’s picture

Wanted to bump the patch from @sylus, I think this needs to be merged (or something similar), how the project current sits at 5.10 throws the error sylus pointed out if you run:

blt tests:behat

I also believe it is breaking Acquia pipeline jobs (the same behat related error).

sylus’s picture

cameron prince’s picture

The tests are deprecated and were only left in place to give those still using them time to pull them into their own project. We see the same error as #8, but worked around the tests remaining in the codebase using this in composer.json:

    "scripts": {
        "post-install-cmd": [
            "rm -rf docroot/modules/contrib/lightning_core/tests"
        ]
    },
alfattal’s picture

I was having the same issue as @skirtley indicated where Acquia Pipeline jobs kept failing with the behat related error. The fix in #11 seems to complement the patch in #10.

bkosborne’s picture

Same #8 error for me, but I'm puzzled as to why running the tests via BLT causes this problem. I've copied the behat contexts to my own folder, added them to my composer classmap. Why is BLT still even looking at ViewsContext.behat.inc file from lighting_core? It shouldn't even know about it. Strange.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sylus’s picture

smulvih2’s picture

#11 worked for me.

Jon Pugh’s picture

FWIW I am still getting the error. I had to fully remove the .behat.inc files to get bin/behat to run.

drupal/lightning_core * 5.14.0
behat/behat v3.13.0
drupal/drupal-extension v5.0.0rc1